diff --git a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h b/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h rename from mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h rename to mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h --- a/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h @@ -1,4 +1,4 @@ -//===- LinalgInterfaceImpl.h - Linalg Impl. of BufferizableOpInterface ----===// +//===- BufferizableOpInterfaceImpl.h - Impl. of BufferizableOpInterface ---===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_LINALGINTERFACEIMPL_H -#define MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_LINALGINTERFACEIMPL_H +#ifndef MLIR_DIALECT_LINALG_BUFFERIZABLEOPINTERFACEIMPL_H +#define MLIR_DIALECT_LINALG_BUFFERIZABLEOPINTERFACEIMPL_H #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" @@ -15,8 +15,6 @@ class DialectRegistry; namespace linalg { -namespace comprehensive_bufferize { -namespace linalg_ext { /// A function that matches anchor OpOperands for InitTensorOp elimination. /// If an OpOperand is matched, the function should populate the SmallVector @@ -53,9 +51,7 @@ void registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry); -} // namespace linalg_ext -} // namespace comprehensive_bufferize } // namespace linalg } // namespace mlir -#endif // MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_LINALGINTERFACEIMPL_H +#endif // MLIR_DIALECT_LINALG_BUFFERIZABLEOPINTERFACEIMPL_H diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt @@ -1,9 +1,6 @@ set(LLVM_OPTIONAL_SOURCES AffineInterfaceImpl.cpp - LinalgInterfaceImpl.cpp ModuleBufferization.cpp - StdInterfaceImpl.cpp - VectorInterfaceImpl.cpp ) add_mlir_dialect_library(MLIRAffineBufferizableOpInterfaceImpl @@ -14,17 +11,6 @@ MLIRBufferization ) -add_mlir_dialect_library(MLIRLinalgBufferizableOpInterfaceImpl - LinalgInterfaceImpl.cpp - - LINK_LIBS PUBLIC - MLIRBufferization - MLIRBufferizationTransforms - MLIRIR - MLIRLinalg - MLIRTensor -) - add_mlir_dialect_library(MLIRModuleBufferization ModuleBufferization.cpp diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp rename from mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp rename to mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp --- a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.cpp @@ -1,4 +1,4 @@ -//===- LinalgInterfaceImpl.cpp - Linalg Impl. of BufferizableOpInterface --===// +//===- BufferizableOpInterfaceImpl.cpp - Impl. of BufferizableOpInterface -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h" +#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h" #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" @@ -17,7 +17,6 @@ using namespace mlir; using namespace linalg; -using namespace comprehensive_bufferize; using namespace mlir::bufferization; namespace { @@ -529,8 +528,7 @@ /// OpOperand. "Anchored" means that there is a path on the reverse SSA use-def /// chain, starting from the OpOperand and always following the aliasing /// OpOperand, that eventually ends at a single InitTensorOp. -LogicalResult -mlir::linalg::comprehensive_bufferize::linalg_ext::eliminateInitTensors( +LogicalResult mlir::linalg::eliminateInitTensors( Operation *op, BufferizationState &state, BufferizationAliasInfo &aliasInfo, AnchorMatchFn anchorMatchFunc, RewriteFn rewriteFunc, SmallVector &newOps) { @@ -632,10 +630,9 @@ /// /// Note that the newly inserted ExtractSliceOp may have to bufferize /// out-of-place due to RaW conflicts. -LogicalResult mlir::linalg::comprehensive_bufferize::linalg_ext:: - insertSliceAnchoredInitTensorEliminationStep( - Operation *op, BufferizationState &state, - BufferizationAliasInfo &aliasInfo, SmallVector &newOps) { +LogicalResult mlir::linalg::insertSliceAnchoredInitTensorEliminationStep( + Operation *op, BufferizationState &state, BufferizationAliasInfo &aliasInfo, + SmallVector &newOps) { return eliminateInitTensors( op, state, aliasInfo, /*anchorMatchFunc=*/ @@ -688,8 +685,8 @@ newOps); } -void mlir::linalg::comprehensive_bufferize::linalg_ext:: - registerBufferizableOpInterfaceExternalModels(DialectRegistry ®istry) { +void mlir::linalg::registerBufferizableOpInterfaceExternalModels( + DialectRegistry ®istry) { registry.addOpInterface(); registry.addOpInterface(); registry.addOpInterface(); diff --git a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt @@ -1,4 +1,5 @@ add_mlir_dialect_library(MLIRLinalgTransforms + BufferizableOpInterfaceImpl.cpp Bufferize.cpp CodegenStrategy.cpp ComprehensiveBufferizePass.cpp @@ -43,7 +44,6 @@ MLIRMemRef MLIRLinalg MLIRLinalgAnalysis - MLIRLinalgBufferizableOpInterfaceImpl MLIRLinalgUtils MLIRModuleBufferization MLIRSCF diff --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp @@ -13,9 +13,9 @@ #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" #include "mlir/Dialect/Linalg/ComprehensiveBufferize/AffineInterfaceImpl.h" -#include "mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h" #include "mlir/Dialect/Linalg/ComprehensiveBufferize/ModuleBufferization.h" #include "mlir/Dialect/Linalg/Passes.h" +#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/SCF/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/Vector/Transforms/BufferizableOpInterfaceImpl.h" @@ -52,7 +52,7 @@ arith::ArithmeticDialect, StandardOpsDialect, AffineDialect>(); affine_ext::registerBufferizableOpInterfaceExternalModels(registry); arith::registerBufferizableOpInterfaceExternalModels(registry); - linalg_ext::registerBufferizableOpInterfaceExternalModels(registry); + linalg::registerBufferizableOpInterfaceExternalModels(registry); scf::registerBufferizableOpInterfaceExternalModels(registry); std_ext::registerModuleBufferizationExternalModels(registry); tensor::registerBufferizableOpInterfaceExternalModels(registry); @@ -98,8 +98,7 @@ opt.printConflicts = printConflicts; opt.testAnalysisOnly = testAnalysisOnly; if (initTensorElimination) { - opt.addPostAnalysisStep( - linalg_ext::insertSliceAnchoredInitTensorEliminationStep); + opt.addPostAnalysisStep(insertSliceAnchoredInitTensorEliminationStep); } } else { opt = *options; diff --git a/mlir/test/lib/Dialect/Linalg/CMakeLists.txt b/mlir/test/lib/Dialect/Linalg/CMakeLists.txt --- a/mlir/test/lib/Dialect/Linalg/CMakeLists.txt +++ b/mlir/test/lib/Dialect/Linalg/CMakeLists.txt @@ -20,7 +20,6 @@ MLIRBufferizationTransforms MLIRGPUTransforms MLIRLinalg - MLIRLinalgBufferizableOpInterfaceImpl MLIRLinalgTransforms MLIRLLVMToLLVMIRTranslation MLIRMemRef diff --git a/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp b/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp --- a/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp +++ b/mlir/test/lib/Dialect/Linalg/TestComprehensiveBufferize.cpp @@ -17,9 +17,9 @@ #include "mlir/Dialect/Bufferization/IR/Bufferization.h" #include "mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h" #include "mlir/Dialect/Linalg/ComprehensiveBufferize/AffineInterfaceImpl.h" -#include "mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h" #include "mlir/Dialect/Linalg/IR/Linalg.h" #include "mlir/Dialect/Linalg/Passes.h" +#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/SCF/BufferizableOpInterfaceImpl.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.h" @@ -59,7 +59,7 @@ arith::ArithmeticDialect, AffineDialect>(); affine_ext::registerBufferizableOpInterfaceExternalModels(registry); arith::registerBufferizableOpInterfaceExternalModels(registry); - linalg_ext::registerBufferizableOpInterfaceExternalModels(registry); + linalg::registerBufferizableOpInterfaceExternalModels(registry); scf::registerBufferizableOpInterfaceExternalModels(registry); tensor::registerBufferizableOpInterfaceExternalModels(registry); vector::registerBufferizableOpInterfaceExternalModels(registry); diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel @@ -6841,25 +6841,6 @@ ], ) -cc_library( - name = "LinalgBufferizableOpInterfaceImpl", - srcs = [ - "lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp", - ], - hdrs = [ - "include/mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h", - ], - includes = ["include"], - deps = [ - ":BufferizationDialect", - ":BufferizationTransforms", - ":IR", - ":LinalgOps", - ":LinalgStructuredOpsIncGen", - ":TensorDialect", - ], -) - td_library( name = "LinalgDocTdFiles", srcs = ["include/mlir/Dialect/Linalg/IR/LinalgDoc.td"], @@ -7050,6 +7031,7 @@ hdrs = [ "include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h", "include/mlir/Dialect/Linalg/Passes.h", + "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterfaceImpl.h", "include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h", "include/mlir/Dialect/Linalg/Transforms/HoistPadding.h", "include/mlir/Dialect/Linalg/Transforms/Hoisting.h", @@ -7073,7 +7055,6 @@ ":DialectUtils", ":IR", ":InferTypeOpInterface", - ":LinalgBufferizableOpInterfaceImpl", ":LinalgOps", ":LinalgPassIncGen", ":LinalgStructuredOpsIncGen", diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -396,7 +396,6 @@ "//mlir:BufferizationTransforms", "//mlir:GPUDialect", "//mlir:IR", - "//mlir:LinalgBufferizableOpInterfaceImpl", "//mlir:LinalgOps", "//mlir:LinalgTransforms", "//mlir:MemRefDialect",