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/SubsetOpInterface.h"
16#include "mlir/Transforms/InliningUtils.h"
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 {
29 using DialectInlinerInterface::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, 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}
70

source code of mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp