19struct ExtractSliceOpSubsetOpInterface
20 :
public SubsetOpInterface::ExternalModel<ExtractSliceOpSubsetOpInterface,
21 tensor::ExtractSliceOp> {
22 FailureOr<HyperrectangularSlice>
23 getAccessedHyperrectangularSlice(Operation *op)
const {
24 return HyperrectangularSlice(cast<OffsetSizeAndStrideOpInterface>(op));
28struct ExtractSliceOpSubsetExtractionOpInterface
29 :
public SubsetExtractionOpInterface::ExternalModel<
30 ExtractSliceOpSubsetExtractionOpInterface, tensor::ExtractSliceOp> {
31 OpOperand &getSourceOperand(Operation *op)
const {
32 return cast<tensor::ExtractSliceOp>(op).getSourceMutable();
36template <
typename OpTy>
37struct InsertSliceLikeOpSubsetOpInterface
38 :
public SubsetOpInterface::ExternalModel<
39 InsertSliceLikeOpSubsetOpInterface<OpTy>, OpTy> {
40 FailureOr<HyperrectangularSlice>
41 getAccessedHyperrectangularSlice(Operation *op)
const {
42 return HyperrectangularSlice(cast<OffsetSizeAndStrideOpInterface>(op));
46template <
typename OpTy>
47struct InsertSliceLikeOpSubsetInsertionOpInterface
48 :
public SubsetInsertionOpInterface::ExternalModel<
49 InsertSliceLikeOpSubsetInsertionOpInterface<OpTy>, OpTy> {
50 OpOperand &getSourceOperand(Operation *op)
const {
51 return cast<OpTy>(op).getSourceMutable();
54 OpOperand &getDestinationOperand(Operation *op)
const {
55 return cast<OpTy>(op).getDestMutable();
60 auto insertSliceOp = cast<OpTy>(op);
61 auto extractOp = tensor::ExtractSliceOp::create(
62 builder, loc, insertSliceOp.getSourceType(), insertSliceOp.getDest(),
63 insertSliceOp.getMixedOffsets(), insertSliceOp.getMixedSizes(),
64 insertSliceOp.getMixedStrides());
65 return extractOp.getResult();
69 getValuesNeededToBuildSubsetExtraction(Operation *op)
const {
70 auto insertSliceOp = cast<OpTy>(op);
71 SmallVector<Value> neededValues;
73 neededValues.append(insertSliceOp.getOffsets().begin(),
74 insertSliceOp.getOffsets().end());
75 neededValues.append(insertSliceOp.getSizes().begin(),
76 insertSliceOp.getSizes().end());
77 neededValues.append(insertSliceOp.getStrides().begin(),
78 insertSliceOp.getStrides().end());
79 neededValues.push_back(insertSliceOp.getDest());
90 ExtractSliceOp::attachInterface<ExtractSliceOpSubsetOpInterface>(*ctx);
91 ExtractSliceOp::attachInterface<ExtractSliceOpSubsetExtractionOpInterface>(
93 InsertSliceOp::attachInterface<
94 InsertSliceLikeOpSubsetOpInterface<InsertSliceOp>>(*ctx);
95 InsertSliceOp::attachInterface<
96 InsertSliceLikeOpSubsetInsertionOpInterface<InsertSliceOp>>(*ctx);
97 ParallelInsertSliceOp::attachInterface<
98 InsertSliceLikeOpSubsetOpInterface<ParallelInsertSliceOp>>(*ctx);
99 ParallelInsertSliceOp::attachInterface<
100 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.