diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h b/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h index 16bb0d87fb6fe7..c035190f43e395 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/Bufferization.h @@ -12,10 +12,10 @@ #include "mlir/Bytecode/BytecodeOpInterface.h" #include "mlir/Dialect/Bufferization/IR/AllocationOpInterface.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" #include "mlir/Interfaces/CopyOpInterface.h" #include "mlir/Interfaces/DestinationStyleOpInterface.h" #include "mlir/Interfaces/InferTypeOpInterface.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" //===----------------------------------------------------------------------===// // Bufferization Dialect diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td index c779d1f843d76a..72a4aa712f49c9 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizationOps.td @@ -12,10 +12,10 @@ include "mlir/Dialect/Bufferization/IR/AllocationOpInterface.td" include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td" include "mlir/Dialect/Bufferization/IR/BufferizationBase.td" -include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td" include "mlir/Interfaces/DestinationStyleOpInterface.td" include "mlir/Interfaces/InferTypeOpInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" +include "mlir/Interfaces/SubsetInsertionOpInterface.td" include "mlir/Interfaces/CopyOpInterface.td" class Bufferization_Op traits = []> diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/CMakeLists.txt b/mlir/include/mlir/Dialect/Bufferization/IR/CMakeLists.txt index 38057d4910d295..31a553f9a32f55 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/Bufferization/IR/CMakeLists.txt @@ -3,7 +3,6 @@ add_mlir_doc(BufferizationOps BufferizationOps Dialects/ -gen-dialect-doc) add_mlir_interface(AllocationOpInterface) add_mlir_interface(BufferDeallocationOpInterface) add_mlir_interface(BufferizableOpInterface) -add_mlir_interface(SubsetInsertionOpInterface) set(LLVM_TARGET_DEFINITIONS BufferizationEnums.td) mlir_tablegen(BufferizationEnums.h.inc -gen-enum-decls) diff --git a/mlir/include/mlir/Interfaces/CMakeLists.txt b/mlir/include/mlir/Interfaces/CMakeLists.txt index 701b46889194da..36a04ff0eaeaf4 100644 --- a/mlir/include/mlir/Interfaces/CMakeLists.txt +++ b/mlir/include/mlir/Interfaces/CMakeLists.txt @@ -12,6 +12,7 @@ add_mlir_interface(ParallelCombiningOpInterface) add_mlir_interface(RuntimeVerifiableOpInterface) add_mlir_interface(ShapedOpInterfaces) add_mlir_interface(SideEffectInterfaces) +add_mlir_interface(SubsetInsertionOpInterface) add_mlir_interface(TilingInterface) add_mlir_interface(ValueBoundsOpInterface) add_mlir_interface(VectorInterfaces) diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h b/mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.h similarity index 67% rename from mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h rename to mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.h index e5b06d746e74bf..3a6dfceadcce7c 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h +++ b/mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.h @@ -6,13 +6,12 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_BUFFERIZATION_IR_SUBSETINSERTIONOPINTERFACE_H_ -#define MLIR_DIALECT_BUFFERIZATION_IR_SUBSETINSERTIONOPINTERFACE_H_ +#ifndef MLIR_INTERFACES_SUBSETINSERTIONOPINTERFACE_H_ +#define MLIR_INTERFACES_SUBSETINSERTIONOPINTERFACE_H_ #include "mlir/IR/OpDefinition.h" namespace mlir { -namespace bufferization { namespace detail { /// Return the destination/"init" operand of the op if it implements the @@ -21,9 +20,8 @@ namespace detail { OpOperand &defaultGetDestinationOperand(Operation *op); } // namespace detail -} // namespace bufferization } // namespace mlir -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h.inc" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h.inc" -#endif // MLIR_DIALECT_BUFFERIZATION_IR_SUBSETINSERTIONOPINTERFACE_H_ +#endif // MLIR_INTERFACES_SUBSETINSERTIONOPINTERFACE_H_ diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td b/mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.td similarity index 96% rename from mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td rename to mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.td index aa09354bc753db..ef94a8ae9a60ef 100644 --- a/mlir/include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td +++ b/mlir/include/mlir/Interfaces/SubsetInsertionOpInterface.td @@ -42,7 +42,7 @@ def SubsetInsertionOpInterface : OpInterface<"SubsetInsertionOpInterface"> { Note: This interface currently assumes that a subset op inserts a single tensor (source) into a destination tensor at a single subset. }]; - let cppNamespace = "::mlir::bufferization"; + let cppNamespace = "::mlir"; let methods = [ InterfaceMethod< /*desc=*/[{ @@ -61,7 +61,7 @@ def SubsetInsertionOpInterface : OpInterface<"SubsetInsertionOpInterface"> { /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return ::mlir::bufferization::detail::defaultGetDestinationOperand( + return ::mlir::detail::defaultGetDestinationOperand( $_op.getOperation()); }] >, @@ -144,7 +144,7 @@ def SubsetInsertionOpInterface : OpInterface<"SubsetInsertionOpInterface"> { /// Note: This function is useful outside of bufferization, where no tensor /// equivalence information is available. bool isSameSubset(OpResult candidate) { - auto subsetOp = cast<::mlir::bufferization::SubsetInsertionOpInterface>( + auto subsetOp = cast<::mlir::SubsetInsertionOpInterface>( getOperation()); return subsetOp.isEquivalentSubset( candidate, [](Value v1, Value v2) { return v1 == v2; }); diff --git a/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt index b1940e40ba3411..385d8dc9364e37 100644 --- a/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/IR/CMakeLists.txt @@ -4,7 +4,6 @@ add_mlir_dialect_library(MLIRBufferizationDialect BufferDeallocationOpInterface.cpp BufferizationOps.cpp BufferizationDialect.cpp - SubsetInsertionOpInterface.cpp UnstructuredControlFlow.cpp ADDITIONAL_HEADER_DIRS @@ -24,6 +23,7 @@ add_mlir_dialect_library(MLIRBufferizationDialect MLIRFunctionInterfaces MLIRIR MLIRSparseTensorDialect + MLIRSubsetInsertionOpInterface MLIRTensorDialect MLIRMemRefDialect ) diff --git a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt index ed8dbd57bf40ba..a6876c7c824e0c 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Bufferization/Transforms/CMakeLists.txt @@ -36,6 +36,7 @@ add_mlir_dialect_library(MLIRBufferizationTransforms MLIRTensorDialect MLIRSCFDialect MLIRSideEffectInterfaces + MLIRSubsetInsertionOpInterface MLIRTransforms MLIRViewLikeInterface MLIRSupport diff --git a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp index 1a5a65bfac132a..6622cfefa76a26 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/EmptyTensorElimination.cpp @@ -10,12 +10,12 @@ #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotModuleBufferize.h" #include "mlir/Dialect/Bufferization/Transforms/Transforms.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/Dominance.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" #include "mlir/Pass/Pass.h" namespace mlir { diff --git a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp index f590e3d9da8e97..0bbfdba2b6e6ef 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp @@ -45,7 +45,6 @@ #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" #include "mlir/Dialect/Bufferization/Transforms/Bufferize.h" #include "mlir/Dialect/Bufferization/Transforms/Transforms.h" #include "mlir/Dialect/Func/IR/FuncOps.h" @@ -55,6 +54,7 @@ #include "mlir/IR/Operation.h" #include "mlir/IR/TypeUtilities.h" #include "mlir/Interfaces/ControlFlowInterfaces.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/SetVector.h" diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt index 4e094609afa6a0..bad246c262979b 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -66,6 +66,7 @@ add_mlir_dialect_library(MLIRLinalgTransforms MLIRSCFTransforms MLIRSCFUtils MLIRPass + MLIRSubsetInsertionOpInterface MLIRSparseTensorDialect MLIRTensorDialect MLIRTensorTilingInterfaceImpl diff --git a/mlir/lib/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.cpp index ef7c1b76e0cd04..e0819082102ef6 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.cpp @@ -8,11 +8,10 @@ #include "mlir/Dialect/Linalg/Transforms/SubsetInsertionOpInterfaceImpl.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" using namespace mlir; -using namespace mlir::bufferization; using namespace mlir::linalg; namespace { diff --git a/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt index 0d148278cec519..a0c172ac52e4be 100644 --- a/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt @@ -30,6 +30,7 @@ add_mlir_dialect_library(MLIRTensorTransforms MLIRMemRefDialect MLIRPass MLIRSCFDialect + MLIRSubsetInsertionOpInterface MLIRTensorDialect MLIRTensorUtils MLIRTilingInterface diff --git a/mlir/lib/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.cpp b/mlir/lib/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.cpp index 85f7796096a42a..dbda9953684f41 100644 --- a/mlir/lib/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.cpp @@ -8,11 +8,10 @@ #include "mlir/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" #include "mlir/Dialect/Tensor/IR/Tensor.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" using namespace mlir; -using namespace mlir::bufferization; using namespace mlir::tensor; namespace { diff --git a/mlir/lib/Interfaces/CMakeLists.txt b/mlir/lib/Interfaces/CMakeLists.txt index 6067a7d8a62926..f74306206d63f1 100644 --- a/mlir/lib/Interfaces/CMakeLists.txt +++ b/mlir/lib/Interfaces/CMakeLists.txt @@ -16,6 +16,7 @@ set(LLVM_OPTIONAL_SOURCES RuntimeVerifiableOpInterface.cpp ShapedOpInterfaces.cpp SideEffectInterfaces.cpp + SubsetInsertionOpInterface.cpp TilingInterface.cpp ValueBoundsOpInterface.cpp VectorInterfaces.cpp @@ -82,6 +83,22 @@ add_mlir_interface_library(ParallelCombiningOpInterface) add_mlir_interface_library(RuntimeVerifiableOpInterface) add_mlir_interface_library(ShapedOpInterfaces) add_mlir_interface_library(SideEffectInterfaces) + +add_mlir_library(MLIRSubsetInsertionOpInterface + SubsetInsertionOpInterface.cpp + + ADDITIONAL_HEADER_DIRS + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Interfaces + + DEPENDS + MLIRDestinationStyleOpInterface + MLIRSubsetInsertionOpInterfaceIncGen + + LINK_LIBS PUBLIC + MLIRDestinationStyleOpInterface + MLIRIR + ) + add_mlir_interface_library(TilingInterface) add_mlir_interface_library(VectorInterfaces) add_mlir_interface_library(ViewLikeInterface) diff --git a/mlir/lib/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp b/mlir/lib/Interfaces/SubsetInsertionOpInterface.cpp similarity index 76% rename from mlir/lib/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp rename to mlir/lib/Interfaces/SubsetInsertionOpInterface.cpp index 19a6fbba403c77..b2b092287f96ba 100644 --- a/mlir/lib/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp +++ b/mlir/lib/Interfaces/SubsetInsertionOpInterface.cpp @@ -6,14 +6,14 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h" +#include "mlir/Interfaces/SubsetInsertionOpInterface.h" #include "mlir/Interfaces/DestinationStyleOpInterface.h" -#include "mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp.inc" +#include "mlir/Interfaces/SubsetInsertionOpInterface.cpp.inc" using namespace mlir; -OpOperand &bufferization::detail::defaultGetDestinationOperand(Operation *op) { +OpOperand &detail::defaultGetDestinationOperand(Operation *op) { auto dstOp = dyn_cast(op); assert(dstOp && "getDestination must be implemented for non-DPS ops"); assert( diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel index 99364fe11e8726..b1bd543ae7fce6 100644 --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -6933,6 +6933,7 @@ cc_library( ":MemRefDialect", ":Pass", ":SCFDialect", + ":SubsetInsertionOpInterface", ":TensorDialect", ":TensorPassIncGen", ":TensorUtils", @@ -10190,7 +10191,7 @@ gentbl_cc_library( td_library( name = "SubsetInsertionOpInterfaceTdFiles", srcs = [ - "include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td", + "include/mlir/Interfaces/SubsetInsertionOpInterface.td", ], includes = ["include"], deps = [ @@ -10203,20 +10204,34 @@ gentbl_cc_library( tbl_outs = [ ( ["-gen-op-interface-decls"], - "include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h.inc", + "include/mlir/Interfaces/SubsetInsertionOpInterface.h.inc", ), ( ["-gen-op-interface-defs"], - "include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp.inc", + "include/mlir/Interfaces/SubsetInsertionOpInterface.cpp.inc", ), ], tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.td", + td_file = "include/mlir/Interfaces/SubsetInsertionOpInterface.td", deps = [ ":SubsetInsertionOpInterfaceTdFiles", ], ) +cc_library( + name = "SubsetInsertionOpInterface", + srcs = ["lib/Interfaces/SubsetInsertionOpInterface.cpp"], + hdrs = ["include/mlir/Interfaces/SubsetInsertionOpInterface.h"], + includes = ["include"], + deps = [ + ":DestinationStyleOpInterface", + ":IR", + ":SubsetInsertionOpInterfaceIncGen", + ":Support", + "//llvm:Support", + ], +) + td_library( name = "LinalgDocTdFiles", srcs = ["include/mlir/Dialect/Linalg/IR/LinalgDoc.td"], @@ -10455,6 +10470,7 @@ cc_library( ":SCFTransforms", ":SCFUtils", ":SparseTensorDialect", + ":SubsetInsertionOpInterface", ":Support", ":TensorDialect", ":TensorTilingInterfaceImpl", @@ -12574,7 +12590,6 @@ cc_library( "lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp", "lib/Dialect/Bufferization/IR/BufferizationDialect.cpp", "lib/Dialect/Bufferization/IR/BufferizationOps.cpp", - "lib/Dialect/Bufferization/IR/SubsetInsertionOpInterface.cpp", "lib/Dialect/Bufferization/IR/UnstructuredControlFlow.cpp", ], hdrs = [ @@ -12582,7 +12597,6 @@ cc_library( "include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h", "include/mlir/Dialect/Bufferization/IR/Bufferization.h", "include/mlir/Dialect/Bufferization/IR/DstBufferizableOpInterfaceImpl.h", - "include/mlir/Dialect/Bufferization/IR/SubsetInsertionOpInterface.h", "include/mlir/Dialect/Bufferization/IR/UnstructuredControlFlow.h", ], includes = ["include"], @@ -12605,7 +12619,7 @@ cc_library( ":InferTypeOpInterface", ":MemRefDialect", ":SparseTensorDialect", - ":SubsetInsertionOpInterfaceIncGen", + ":SubsetInsertionOpInterface", ":Support", ":TensorDialect", "//llvm:Support", @@ -12655,6 +12669,7 @@ cc_library( ":Pass", ":SCFDialect", ":SideEffectInterfaces", + ":SubsetInsertionOpInterface", ":Support", ":TensorDialect", ":Transforms",