1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "mlir/Dialect/Affine/IR/AffineOps.h" |
10 | #include "mlir/Dialect/Arith/IR/Arith.h" |
11 | #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" |
12 | #include "mlir/Dialect/Complex/IR/Complex.h" |
13 | #include "mlir/Dialect/Tensor/IR/Tensor.h" |
14 | #include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h" |
15 | #include "mlir/Interfaces/RuntimeVerifiableOpInterface.h" |
16 | #include "mlir/Interfaces/SubsetOpInterface.h" |
17 | #include "mlir/Transforms/InliningUtils.h" |
18 | |
19 | using namespace mlir; |
20 | using namespace mlir::tensor; |
21 | |
22 | #include "mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc" |
23 | |
24 | //===----------------------------------------------------------------------===// |
25 | // TensorDialect Dialect Interfaces |
26 | //===----------------------------------------------------------------------===// |
27 | |
28 | namespace { |
29 | struct TensorInlinerInterface : public DialectInlinerInterface { |
30 | using DialectInlinerInterface::DialectInlinerInterface; |
31 | bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned, |
32 | IRMapping &valueMapping) const final { |
33 | return true; |
34 | } |
35 | bool isLegalToInline(Operation *, Region *, bool wouldBeCloned, |
36 | IRMapping &) const final { |
37 | return true; |
38 | } |
39 | }; |
40 | } // namespace |
41 | |
42 | //===----------------------------------------------------------------------===// |
43 | // TensorDialect Methods |
44 | //===----------------------------------------------------------------------===// |
45 | |
46 | void TensorDialect::initialize() { |
47 | addOperations< |
48 | #define GET_OP_LIST |
49 | #include "mlir/Dialect/Tensor/IR/TensorOps.cpp.inc" |
50 | >(); |
51 | addInterfaces<TensorInlinerInterface>(); |
52 | declarePromisedInterfaces< |
53 | bufferization::BufferizableOpInterface, CastOp, CollapseShapeOp, ConcatOp, |
54 | DimOp, EmptyOp, ExpandShapeOp, ExtractSliceOp, ExtractOp, FromElementsOp, |
55 | GenerateOp, InsertOp, InsertSliceOp, PadOp, ParallelInsertSliceOp, RankOp, |
56 | ReshapeOp, SplatOp>(); |
57 | declarePromisedInterfaces<transform::FindPayloadReplacementOpInterface, |
58 | CollapseShapeOp, ExpandShapeOp, ExtractSliceOp, |
59 | InsertSliceOp, ReshapeOp>(); |
60 | declarePromisedInterfaces<ReifyRankedShapedTypeOpInterface, ExpandShapeOp, |
61 | CollapseShapeOp, PadOp>(); |
62 | declarePromisedInterfaces<RuntimeVerifiableOpInterface, CastOp, DimOp, |
63 | ExtractOp, InsertOp, ExtractSliceOp>(); |
64 | declarePromisedInterfaces<SubsetOpInterface, ExtractSliceOp, InsertSliceOp, |
65 | ParallelInsertSliceOp>(); |
66 | declarePromisedInterfaces<SubsetInsertionOpInterface, InsertSliceOp, |
67 | ParallelInsertSliceOp>(); |
68 | declarePromisedInterface<SubsetExtractionOpInterface, ExtractSliceOp>(); |
69 | declarePromisedInterfaces<TilingInterface, PadOp>(); |
70 | declarePromisedInterfaces<ValueBoundsOpInterface, CastOp, DimOp, EmptyOp, |
71 | ExtractSliceOp, PadOp, RankOp>(); |
72 | } |
73 | |