diff --git a/mlir/include/mlir/Dialect/Linalg/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/CMakeLists.txt --- a/mlir/include/mlir/Dialect/Linalg/CMakeLists.txt +++ b/mlir/include/mlir/Dialect/Linalg/CMakeLists.txt @@ -1,5 +1,5 @@ +add_subdirectory(ComprehensiveBufferize) add_subdirectory(IR) -add_subdirectory(Transforms) set(LLVM_TARGET_DEFINITIONS Passes.td) mlir_tablegen(Passes.h.inc -gen-pass-decls -name Linalg) diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h rename from mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h rename to mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE_H_ -#define MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE_H_ +#ifndef MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_ +#define MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_ #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinTypes.h" @@ -31,6 +31,6 @@ } // namespace linalg } // namespace mlir -#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h.inc" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h.inc" -#endif // MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE_H_ +#endif // MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_BUFFERIZABLEOPINTERFACE_H_ diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td rename from mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td rename to mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td --- a/mlir/include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td +++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE -#define MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE +#ifndef BUFFERIZABLE_OP_INTERFACE +#define BUFFERIZABLE_OP_INTERFACE include "mlir/IR/OpBase.td" @@ -150,4 +150,4 @@ ]; } -#endif // MLIR_DIALECT_LINALG_TRANSFORMS_BUFFERIZABLEOPINTERFACE +#endif // BUFFERIZABLE_OP_INTERFACE diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/CMakeLists.txt b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt rename from mlir/include/mlir/Dialect/Linalg/Transforms/CMakeLists.txt rename to mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h rename from mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h rename to mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h +++ b/mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_DIALECT_LINALG_TRANSFORMS_COMPREHENSIVE_BUFFERIZE_H -#define MLIR_DIALECT_LINALG_TRANSFORMS_COMPREHENSIVE_BUFFERIZE_H +#ifndef MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_COMPREHENSIVE_BUFFERIZE_H +#define MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_COMPREHENSIVE_BUFFERIZE_H #include "mlir/Dialect/Tensor/IR/Tensor.h" #include "mlir/IR/Value.h" @@ -19,9 +19,13 @@ class DominanceInfo; class FuncOp; class GlobalCreator; +class ModuleOp; namespace linalg { +// TODO: from some HW description. +static constexpr int64_t kBufferAlignments = 128; + /// The BufferizationAliasInfo class maintains a list of buffer aliases and /// equivalence classes to support bufferization. /// ExtractSliceOps have special behavior, they act as a level of indirection @@ -120,6 +124,7 @@ const DominanceInfo &domInfo, unsigned analysisFuzzerSeed = 0); +// TODO: Do not expose those functions in the header file. /// Default allocation function that is used by the comprehensive bufferization /// pass. The default currently creates a ranked memref using `memref.alloc`. Optional defaultAllocationFn(OpBuilder &b, Location loc, MemRefType type, @@ -149,6 +154,10 @@ MemCpyFn copyFn) : allocationFn(allocFn), deallocationFn(deallocFn), memCpyFn(copyFn) {} + AllocationCallbacks() + : allocationFn(defaultAllocationFn), + deallocationFn(defaultDeallocationFn), memCpyFn(defaultMemCpyFn) {} + AllocationFn allocationFn; DeallocationFn deallocationFn; MemCpyFn memCpyFn; @@ -165,7 +174,21 @@ /// Register external models implemented for the `BufferizableOpInterface`. void registerBufferiableOpInterfaceExternalModels(DialectRegistry ®istry); + +struct BufferizationOptions { + BufferizationOptions() + : allocationFns(std::make_unique()) {} + + std::unique_ptr allocationFns; + bool allowReturnMemref = false; + unsigned analysisFuzzerSeed = 0; + bool testAnalysisOnly = false; +}; + +LogicalResult runComprehensiveBufferize(ModuleOp moduleOp, + const BufferizationOptions &options); + } // namespace linalg } // namespace mlir -#endif // define MLIR_DIALECT_LINALG_TRANSFORMS_COMPREHENSIVE_BUFFERIZE_H +#endif // MLIR_DIALECT_LINALG_COMPREHENSIVEBUFFERIZE_COMPREHENSIVE_BUFFERIZE_H diff --git a/mlir/lib/Dialect/Linalg/CMakeLists.txt b/mlir/lib/Dialect/Linalg/CMakeLists.txt --- a/mlir/lib/Dialect/Linalg/CMakeLists.txt +++ b/mlir/lib/Dialect/Linalg/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(Analysis) +add_subdirectory(ComprehensiveBufferize) add_subdirectory(IR) add_subdirectory(Transforms) add_subdirectory(Utils) diff --git a/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp rename from mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp rename to mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp @@ -6,12 +6,12 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h" namespace mlir { namespace linalg { -#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp.inc" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp.inc" } // namespace linalg } // namespace mlir diff --git a/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/CMakeLists.txt @@ -0,0 +1,30 @@ +set(LLVM_OPTIONAL_SOURCES + BufferizableOpInterface.cpp + ComprehensiveBufferize.cpp +) + +add_mlir_dialect_library(MLIRBufferizableOpInterface + BufferizableOpInterface.cpp + + DEPENDS + MLIRBufferizableOpInterfaceIncGen + + LINK_LIBS PUBLIC + MLIRIR +) + +add_mlir_dialect_library(MLIRComprehensiveBufferize + ComprehensiveBufferize.cpp + + LINK_LIBS PUBLIC + MLIRBufferizableOpInterface + MLIRInferTypeOpInterface + MLIRIR + MLIRMemRef + MLIRLinalg + MLIRSCF + MLIRStandard + MLIRStandardOpsTransforms + MLIRTensor + MLIRVector +) diff --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp rename from mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp rename to mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp +++ b/mlir/lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp @@ -105,16 +105,12 @@ // expected layouts after transformations. Combinations of memref.cast + // canonicalization are responsible for clean ups. -#include "mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h" #include -#include "PassDetail.h" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" -#include "mlir/Dialect/Linalg/Passes.h" -#include "mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h" -#include "mlir/Dialect/Linalg/Transforms/Transforms.h" -#include "mlir/Dialect/Linalg/Utils/Utils.h" #include "mlir/Dialect/MemRef/IR/MemRef.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/Utils/StaticValueUtils.h" @@ -125,8 +121,6 @@ #include "mlir/Pass/Pass.h" #include "mlir/Pass/PassManager.h" #include "mlir/Transforms/BufferUtils.h" -#include "mlir/Transforms/GreedyPatternRewriteDriver.h" -#include "mlir/Transforms/Passes.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/SetVector.h" @@ -142,9 +136,6 @@ #define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ") #define LDBG(X) LLVM_DEBUG(DBGS() << X) -// TODO: from some HW description. -static constexpr int64_t kBufferAlignments = 128; - // Forward declarations. static std::string printOperationInfo(Operation *, bool prefix = true); static std::string printValueInfo(Value, bool prefix = true); @@ -1200,6 +1191,17 @@ return nullptr; } +/// Helper function that creates a memref::DimOp or tensor::DimOp depending on +/// the type of `source`. +static Value createOrFoldDimOp(OpBuilder &b, Location loc, Value source, + int64_t dim) { + if (source.getType().isa()) + return b.createOrFold(loc, source, dim); + if (source.getType().isa()) + return b.createOrFold(loc, source, dim); + llvm_unreachable("Expected MemRefType or TensorType"); +} + /// Compute the type of the `memref` to use for allocating the buffer for /// `shapedValue`. Also returns (by reference in `dynShape`), the value for the /// dynamic dimensions in the returned `memref` type. The function also sets the @@ -1656,14 +1658,6 @@ return allocated; } -static Optional -allocationFnUsingAlloca(OpBuilder &b, Location loc, MemRefType type, - const SmallVector &dynShape) { - Value allocated = b.create( - loc, type, dynShape, b.getI64IntegerAttr(kBufferAlignments)); - return allocated; -} - void mlir::linalg::defaultDeallocationFn(OpBuilder &b, Location loc, Value allocatedBuffer) { b.create(loc, allocatedBuffer); @@ -2010,36 +2004,6 @@ return success(); } -namespace { -struct LinalgComprehensiveModuleBufferize - : public LinalgComprehensiveModuleBufferizeBase< - LinalgComprehensiveModuleBufferize> { - LinalgComprehensiveModuleBufferize() {} - - LinalgComprehensiveModuleBufferize( - const LinalgComprehensiveModuleBufferize &p) {} - - void runOnOperation() override; - - void getDependentDialects(DialectRegistry ®istry) const override { - registry - .insert(); - registerBufferiableOpInterfaceExternalModels(registry); - } - -private: - std::unique_ptr allocationFns; -}; -} // end namespace - -static void applyEnablingTransformations(ModuleOp moduleOp) { - RewritePatternSet patterns(moduleOp.getContext()); - patterns.add(moduleOp.getContext()); - (void)applyPatternsAndFoldGreedily(moduleOp, std::move(patterns)); -} - static void foreachCaller(const DenseMap> &callerMap, FuncOp callee, llvm::function_ref doit) { @@ -2215,33 +2179,14 @@ return failure(status.wasInterrupted()); } -void LinalgComprehensiveModuleBufferize::runOnOperation() { - if (!allocationFns) { - // The allocation functions to use needs to be set here. The flag for the - // pass and flag for the use of alloca map to LLVM command line - // options. These being static global objects have no set order in which - // they are defined. So ideally this should be in the constructor, but the - // constructor might be called before the flag is initialized using the - // command line option. So this is set up at the start of the pass. - if (useAlloca) { - AllocationCallbacks allocaAllocationFns = { - allocationFnUsingAlloca, [](OpBuilder &b, Location loc, Value v) {}, - defaultMemCpyFn}; - allocationFns = - std::make_unique(std::move(allocaAllocationFns)); - } else { - allocationFns = std::make_unique( - defaultAllocationFn, defaultDeallocationFn, defaultMemCpyFn); - } - } - ModuleOp moduleOp = getOperation(); - applyEnablingTransformations(moduleOp); - +LogicalResult +mlir::linalg::runComprehensiveBufferize(ModuleOp moduleOp, + const BufferizationOptions &options) { SmallVector orderedFuncOps; DenseMap> callerMap; DenseMap bufferizedFunctionTypes; if (failed(getFuncOpsOrderedByCalls(moduleOp, orderedFuncOps, callerMap))) - return signalPassFailure(); + return failure(); DominanceInfo domInfo(moduleOp); BufferizationAliasInfo aliasInfo(moduleOp); @@ -2267,48 +2212,40 @@ // If the analysis fails, just return. if (failed(inPlaceAnalysisFuncOpBody(funcOp, aliasInfo, domInfo, - analysisFuzzerSeed))) { - signalPassFailure(); - return; - } + options.analysisFuzzerSeed))) + return failure(); // Try to eliminate InitTensorOps to avoid new allocations during the // bufferization phase. - if (failed(runInitTensorElimination(funcOp, aliasInfo, domInfo))) { - signalPassFailure(); - return; - } + if (failed(runInitTensorElimination(funcOp, aliasInfo, domInfo))) + return failure(); // Bufferization phase. - if (!testAnalysisOnly) { + if (!options.testAnalysisOnly) { BlockAndValueMapping tensorToBufferMap; if (failed(bufferizeFuncOpInternals(funcOp, tensorToBufferMap, aliasInfo, - *allocationFns, - bufferizedFunctionTypes))) { - signalPassFailure(); - return; - } + *options.allocationFns, + bufferizedFunctionTypes))) + return failure(); } } // Don't drop the attributes if we only want to report the analysis. - if (testAnalysisOnly) - return; + if (options.testAnalysisOnly) + return success(); for (FuncOp funcOp : orderedFuncOps) { // Note: It would be good to apply cleanups here but we cannot as aliasInfo // would be invalidated. if (failed(bufferizeFuncOpBoundary(funcOp, aliasInfo, - bufferizedFunctionTypes))) { - signalPassFailure(); - return; - } - if (!allowReturnMemref && + bufferizedFunctionTypes))) + return failure(); + + if (!options.allowReturnMemref && llvm::any_of(funcOp.getType().getResults(), [](Type t) { return t.isa(); })) { funcOp->emitError("memref return type is unsupported"); - signalPassFailure(); - return; + return failure(); } } @@ -2324,15 +2261,7 @@ removeBufferizationFuncArguments(bbArg); }); - OpPassManager cleanupPipeline("builtin.module"); - cleanupPipeline.addPass(createCanonicalizerPass()); - cleanupPipeline.addPass(createCSEPass()); - cleanupPipeline.addPass(createLoopInvariantCodeMotionPass()); - (void)runPipeline(cleanupPipeline, moduleOp); -} - -std::unique_ptr mlir::createLinalgComprehensiveModuleBufferizePass() { - return std::make_unique(); + return success(); } //===----------------------------------------------------------------------===// @@ -3470,7 +3399,8 @@ /// Helper structure that iterates over all LinalgOps in `OpTys` and registers /// the `BufferizableOpInterface` with each of them. -template struct LinalgOpInterfaceHelper; +template +struct LinalgOpInterfaceHelper; template struct LinalgOpInterfaceHelper { @@ -3480,7 +3410,8 @@ } }; -template <> struct LinalgOpInterfaceHelper<> { +template <> +struct LinalgOpInterfaceHelper<> { static void registerOpInterface(DialectRegistry ®istry) {} }; 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,42 +1,7 @@ -set(LLVM_OPTIONAL_SOURCES - Bufferize.cpp - BufferizableOpInterface.cpp - CodegenStrategy.cpp - ComprehensiveBufferize.cpp - Detensorize.cpp - Distribution.cpp - DropUnitDims.cpp - ElementwiseOpFusion.cpp - ElementwiseToLinalg.cpp - Fusion.cpp - FusionOnTensors.cpp - Generalization.cpp - Hoisting.cpp - HoistPadding.cpp - InlineScalarOperands.cpp - Interchange.cpp - Loops.cpp - LinalgStrategyPasses.cpp - Promotion.cpp - Tiling.cpp - Transforms.cpp - Vectorization.cpp -) - -add_mlir_dialect_library(MLIRBufferizableOpInterface - BufferizableOpInterface.cpp - - DEPENDS - MLIRBufferizableOpInterfaceIncGen - - LINK_LIBS PUBLIC - MLIRIR -) - add_mlir_dialect_library(MLIRLinalgTransforms Bufferize.cpp CodegenStrategy.cpp - ComprehensiveBufferize.cpp + ComprehensiveBufferizePass.cpp Detensorize.cpp Distribution.cpp DropUnitDims.cpp @@ -69,6 +34,7 @@ MLIRArithmetic MLIRBufferizableOpInterface MLIRComplex + MLIRComprehensiveBufferize MLIRInferTypeOpInterface MLIRIR MLIRMemRef diff --git a/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp new file mode 100644 --- /dev/null +++ b/mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferizePass.cpp @@ -0,0 +1,84 @@ +//===- ComprehensiveBufferize.cpp - Single pass bufferization -------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "PassDetail.h" +#include "mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h" +#include "mlir/Dialect/Linalg/Passes.h" +#include "mlir/Pass/Pass.h" +#include "mlir/Pass/PassManager.h" +#include "mlir/Transforms/GreedyPatternRewriteDriver.h" +#include "mlir/Transforms/Passes.h" + +using namespace mlir; +using namespace mlir::linalg; + +namespace { +struct LinalgComprehensiveModuleBufferize + : public LinalgComprehensiveModuleBufferizeBase< + LinalgComprehensiveModuleBufferize> { + LinalgComprehensiveModuleBufferize() {} + + LinalgComprehensiveModuleBufferize( + const LinalgComprehensiveModuleBufferize &p) {} + + void runOnOperation() override; + + void getDependentDialects(DialectRegistry ®istry) const override { + registry + .insert(); + registerBufferiableOpInterfaceExternalModels(registry); + } +}; +} // end namespace + +static void applyEnablingTransformations(ModuleOp moduleOp) { + RewritePatternSet patterns(moduleOp.getContext()); + patterns.add(moduleOp.getContext()); + (void)applyPatternsAndFoldGreedily(moduleOp, std::move(patterns)); +} + +static Optional +allocationFnUsingAlloca(OpBuilder &b, Location loc, MemRefType type, + const SmallVector &dynShape) { + Value allocated = b.create( + loc, type, dynShape, b.getI64IntegerAttr(kBufferAlignments)); + return allocated; +} + +void LinalgComprehensiveModuleBufferize::runOnOperation() { + BufferizationOptions options; + if (useAlloca) { + options.allocationFns->allocationFn = allocationFnUsingAlloca; + options.allocationFns->deallocationFn = [](OpBuilder &b, Location loc, + Value v) {}; + } + options.allowReturnMemref = allowReturnMemref; + options.analysisFuzzerSeed = analysisFuzzerSeed; + options.testAnalysisOnly = testAnalysisOnly; + + ModuleOp moduleOp = getOperation(); + applyEnablingTransformations(moduleOp); + + if (failed(runComprehensiveBufferize(moduleOp, options))) + signalPassFailure(); + + if (options.testAnalysisOnly) + return; + + OpPassManager cleanupPipeline("builtin.module"); + cleanupPipeline.addPass(createCanonicalizerPass()); + cleanupPipeline.addPass(createCSEPass()); + cleanupPipeline.addPass(createLoopInvariantCodeMotionPass()); + (void)runPipeline(cleanupPipeline, moduleOp); +} + +std::unique_ptr mlir::createLinalgComprehensiveModuleBufferizePass() { + return std::make_unique(); +} 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 @@ -6113,7 +6113,7 @@ td_library( name = "BufferizableOpInterfaceTdFiles", srcs = [ - "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td", + "include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td", ], includes = ["include"], deps = [ @@ -6127,15 +6127,15 @@ tbl_outs = [ ( ["-gen-op-interface-decls"], - "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h.inc", + "include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h.inc", ), ( ["-gen-op-interface-defs"], - "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp.inc", + "include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp.inc", ), ], tblgen = ":mlir-tblgen", - td_file = "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.td", + td_file = "include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.td", deps = [ ":BufferizableOpInterfaceTdFiles", ], @@ -6144,10 +6144,10 @@ cc_library( name = "BufferizableOpInterface", srcs = [ - "lib/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp", + "lib/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.cpp", ], hdrs = [ - "include/mlir/Dialect/Linalg/Transforms/BufferizableOpInterface.h", + "include/mlir/Dialect/Linalg/ComprehensiveBufferize/BufferizableOpInterface.h", ], includes = ["include"], deps = [ @@ -6336,13 +6336,10 @@ cc_library( name = "LinalgTransforms", - srcs = glob( - [ - "lib/Dialect/Linalg/Transforms/*.cpp", - "lib/Dialect/Linalg/Transforms/*.h", - ], - exclude = ["lib/Dialect/Linalg/Transforms/BufferizableOpInterface.cpp"], - ) + [ + srcs = glob([ + "lib/Dialect/Linalg/Transforms/*.cpp", + "lib/Dialect/Linalg/Transforms/*.h", + ]) + [ "lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp", "lib/Dialect/Linalg/Utils/Utils.cpp", ], @@ -6350,7 +6347,6 @@ "include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h", "include/mlir/Dialect/Linalg/Passes.h", "include/mlir/Dialect/Linalg/Transforms/CodegenStrategy.h", - "include/mlir/Dialect/Linalg/Transforms/ComprehensiveBufferize.h", "include/mlir/Dialect/Linalg/Transforms/HoistPadding.h", "include/mlir/Dialect/Linalg/Transforms/Hoisting.h", "include/mlir/Dialect/Linalg/Transforms/Transforms.h", @@ -6362,8 +6358,8 @@ ":AffineUtils", ":Analysis", ":ArithmeticDialect", - ":BufferizableOpInterface", ":ComplexDialect", + ":ComprehensiveBufferize", ":DialectUtils", ":IR", ":InferTypeOpInterface", @@ -6386,6 +6382,35 @@ ], ) +cc_library( + name = "ComprehensiveBufferize", + srcs = [ + "lib/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.cpp", + ], + hdrs = [ + "include/mlir/Dialect/Linalg/ComprehensiveBufferize/ComprehensiveBufferize.h", + ], + includes = ["include"], + deps = [ + ":ArithmeticDialect", + ":BufferizableOpInterface", + ":DialectUtils", + ":IR", + ":InferTypeOpInterface", + ":LinalgOps", + ":LinalgStructuredOpsIncGen", + ":MemRefDialect", + ":Pass", + ":SCFDialect", + ":StandardOps", + ":Support", + ":TensorDialect", + ":TransformUtils", + ":VectorOps", + "//llvm:Support", + ], +) + cc_library( name = "TilingInterface", srcs = ["lib/Interfaces/TilingInterface.cpp"],