20struct ExtractSliceOpSubsetOpInterface
21 :
public SubsetOpInterface::ExternalModel<ExtractSliceOpSubsetOpInterface,
22 tensor::ExtractSliceOp> {
23 FailureOr<HyperrectangularSlice>
24 getAccessedHyperrectangularSlice(Operation *op)
const {
25 return HyperrectangularSlice(cast<OffsetSizeAndStrideOpInterface>(op));
29struct ExtractSliceOpSubsetExtractionOpInterface
30 :
public SubsetExtractionOpInterface::ExternalModel<
31 ExtractSliceOpSubsetExtractionOpInterface, tensor::ExtractSliceOp> {
32 OpOperand &getSourceOperand(Operation *op)
const {
33 return cast<tensor::ExtractSliceOp>(op).getSourceMutable();
37template <
typename OpTy>
38struct InsertSliceLikeOpSubsetOpInterface
39 :
public SubsetOpInterface::ExternalModel<
40 InsertSliceLikeOpSubsetOpInterface<OpTy>, OpTy> {
41 FailureOr<HyperrectangularSlice>
42 getAccessedHyperrectangularSlice(Operation *op)
const {
43 return HyperrectangularSlice(cast<OffsetSizeAndStrideOpInterface>(op));
47template <
typename OpTy>
48struct InsertSliceLikeOpSubsetInsertionOpInterface
49 :
public SubsetInsertionOpInterface::ExternalModel<
50 InsertSliceLikeOpSubsetInsertionOpInterface<OpTy>, OpTy> {
51 OpOperand &getSourceOperand(Operation *op)
const {
52 return cast<OpTy>(op).getSourceMutable();
55 OpOperand &getDestinationOperand(Operation *op)
const {
56 return cast<OpTy>(op).getDestMutable();
61 auto insertSliceOp = cast<OpTy>(op);
62 auto extractOp = tensor::ExtractSliceOp::create(
63 builder, loc, insertSliceOp.getSourceType(), insertSliceOp.getDest(),
64 insertSliceOp.getMixedOffsets(), insertSliceOp.getMixedSizes(),
65 insertSliceOp.getMixedStrides());
66 return extractOp.getResult();
70 getValuesNeededToBuildSubsetExtraction(Operation *op)
const {
71 auto insertSliceOp = cast<OpTy>(op);
72 SmallVector<Value> neededValues;
74 neededValues.append(insertSliceOp.getOffsets().begin(),
75 insertSliceOp.getOffsets().end());
76 neededValues.append(insertSliceOp.getSizes().begin(),
77 insertSliceOp.getSizes().end());
78 neededValues.append(insertSliceOp.getStrides().begin(),
79 insertSliceOp.getStrides().end());
80 neededValues.push_back(insertSliceOp.getDest());
92 ExtractSliceOp::attachInterface<ExtractSliceOpSubsetOpInterface>(*ctx);
93 ExtractSliceOp::attachInterface<ExtractSliceOpSubsetExtractionOpInterface>(
95 InsertSliceOp::attachInterface<
96 InsertSliceLikeOpSubsetOpInterface<InsertSliceOp>>(*ctx);
97 InsertSliceOp::attachInterface<
98 InsertSliceLikeOpSubsetInsertionOpInterface<InsertSliceOp>>(*ctx);
99 ParallelInsertSliceOp::attachInterface<
100 InsertSliceLikeOpSubsetOpInterface<ParallelInsertSliceOp>>(*ctx);
101 ParallelInsertSliceOp::attachInterface<
102 InsertSliceLikeOpSubsetInsertionOpInterface<ParallelInsertSliceOp>>(
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
MLIRContext is the top-level object for a collection of MLIR operations.
Value buildSubsetExtraction(RewriterBase &rewriter, SubsetInsertionOpInterface op, tensor::EmptyOp emptyTensorOp, Operation *user)
This method builds and returns a subset extraction value for the destination tensor that the given op...
void registerSubsetOpInterfaceExternalModels(DialectRegistry ®istry)
Include the generated interface declarations.