72 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "mlir/Dialect/Affine/IR/AffineOps.h"10#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"11#include "mlir/Dialect/Complex/IR/Complex.h"12#include "mlir/Dialect/Tensor/IR/Tensor.h"13#include "mlir/Dialect/Transform/Interfaces/TransformInterfaces.h"14#include "mlir/Interfaces/RuntimeVerifiableOpInterface.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 Interfaces25//===----------------------------------------------------------------------===//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} // namespace40 41//===----------------------------------------------------------------------===//42// TensorDialect Methods43//===----------------------------------------------------------------------===//44 45void TensorDialect::initialize() {46 addOperations<47#define GET_OP_LIST48#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}72