MLIR 22.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
18using namespace mlir;
19using namespace mlir::tensor;
20
21#include "mlir/Dialect/Tensor/IR/TensorOpsDialect.cpp.inc"
22
23//===----------------------------------------------------------------------===//
24// TensorDialect Dialect Interfaces
25//===----------------------------------------------------------------------===//
26
27namespace {
28struct 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
45void 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, ConcatOp,
53 DimOp, 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<RuntimeVerifiableOpInterface, CastOp, DimOp,
62 ExtractOp, InsertOp, ExtractSliceOp>();
63 declarePromisedInterfaces<SubsetOpInterface, ExtractSliceOp, InsertSliceOp,
64 ParallelInsertSliceOp>();
65 declarePromisedInterfaces<SubsetInsertionOpInterface, InsertSliceOp,
66 ParallelInsertSliceOp>();
67 declarePromisedInterface<SubsetExtractionOpInterface, ExtractSliceOp>();
68 declarePromisedInterfaces<TilingInterface, PadOp>();
69 declarePromisedInterfaces<ValueBoundsOpInterface, CastOp, DimOp, EmptyOp,
70 ExtractSliceOp, PadOp, RankOp>();
71}
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.
DialectInlinerInterface(Dialect *dialect)
Include the generated interface declarations.