MLIR  21.0.0git
TensorDialect.cpp
Go to the documentation of this file.
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 
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 {
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 }
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
This is the interface that must be implemented by the dialects of operations to be inlined.
Definition: InliningUtils.h:44
DialectInlinerInterface(Dialect *dialect)
Definition: InliningUtils.h:46
This is a utility class for mapping one set of IR entities to another.
Definition: IRMapping.h:26
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition: Region.h:26
Include the generated interface declarations.