MLIR  19.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 
17 
18 using namespace mlir;
19 using namespace mlir::tensor;
20 
21 #include "mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc"
22 
23 //===----------------------------------------------------------------------===//
24 // TensorDialect Dialect Interfaces
25 //===----------------------------------------------------------------------===//
26 
27 namespace {
28 struct TensorInlinerInterface : public DialectInlinerInterface {
30  bool isLegalToInline(Region *dest, Region *src, bool wouldBeCloned,
31  IRMapping &valueMapping) const final {
32  return true;
33  }
34  bool isLegalToInline(Operation *, Region *, bool wouldBeCloned,
35  IRMapping &) const final {
36  return true;
37  }
38 };
39 } // namespace
40 
41 //===----------------------------------------------------------------------===//
42 // TensorDialect Methods
43 //===----------------------------------------------------------------------===//
44 
45 void TensorDialect::initialize() {
46  addOperations<
47 #define GET_OP_LIST
48 #include "mlir/Dialect/Tensor/IR/TensorOps.cpp.inc"
49  >();
50  addInterfaces<TensorInlinerInterface>();
51  declarePromisedInterfaces<
52  bufferization::BufferizableOpInterface, CastOp, CollapseShapeOp, DimOp,
53  EmptyOp, ExpandShapeOp, ExtractSliceOp, ExtractOp, FromElementsOp,
54  GenerateOp, InsertOp, InsertSliceOp, PadOp, ParallelInsertSliceOp, RankOp,
55  ReshapeOp, SplatOp>();
56  declarePromisedInterfaces<transform::FindPayloadReplacementOpInterface,
57  CollapseShapeOp, ExpandShapeOp, ExtractSliceOp,
58  InsertSliceOp, ReshapeOp>();
59  declarePromisedInterfaces<ReifyRankedShapedTypeOpInterface, ExpandShapeOp,
60  CollapseShapeOp, PadOp>();
61  declarePromisedInterfaces<SubsetOpInterface, ExtractSliceOp, InsertSliceOp,
62  ParallelInsertSliceOp>();
63  declarePromisedInterfaces<SubsetInsertionOpInterface, InsertSliceOp,
64  ParallelInsertSliceOp>();
65  declarePromisedInterface<SubsetExtractionOpInterface, ExtractSliceOp>();
66  declarePromisedInterfaces<TilingInterface, PadOp, PackOp, UnPackOp>();
67  declarePromisedInterfaces<ValueBoundsOpInterface, CastOp, DimOp, EmptyOp,
68  ExtractSliceOp, PadOp, RankOp>();
69 }
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.