34 #define GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION
35 #include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"
37 namespace sparse_tensor {
60 :
public impl::SparsificationAndBufferizationBase<
61 SparsificationAndBufferizationPass> {
67 bool createSparseDeallocs,
bool enableRuntimeLibrary,
68 bool enableBufferInitialization)
69 : bufferizationOptions(bufferizationOptions),
70 sparsificationOptions(sparsificationOptions),
71 createSparseDeallocs(createSparseDeallocs),
72 enableRuntimeLibrary(enableRuntimeLibrary),
73 enableBufferInitialization(enableBufferInitialization) {}
78 bool createSparseDeallocs,
bool enableRuntimeLibrary,
79 bool enableBufferInitialization,
unsigned vl,
bool vla,
bool index32,
82 : bufferizationOptions(bufferizationOptions),
83 sparsificationOptions(sparsificationOptions),
84 createSparseDeallocs(createSparseDeallocs),
85 enableRuntimeLibrary(enableRuntimeLibrary),
86 enableBufferInitialization(enableBufferInitialization) {
89 enableVLAVectorization = vla;
90 enableSIMDIndex32 = index32;
91 enableGPULibgen = gpu;
92 sparseEmitStrategy = emitStrategy;
93 parallelization = parallelizationStrategy;
101 bufferizationOptions;
107 if (
auto funcOp = dyn_cast<func::FuncOp>(op)) {
108 FunctionType funcType = funcOp.getFunctionType();
119 bufferizationState)))
138 bufferization::createEmptyTensorToAllocTensorPass());
139 if (failed(runPipeline(pm, getOperation())))
140 return signalPassFailure();
156 getOperation(), bufferizationOptions, bufferizationState)))
157 return signalPassFailure();
187 if (vectorLength > 0) {
189 vectorLength, enableVLAVectorization, enableSIMDIndex32));
191 if (enableRuntimeLibrary) {
195 enableBufferInitialization));
198 if (failed(runPipeline(pm, getOperation())))
199 return signalPassFailure();
210 bool createSparseDeallocs;
211 bool enableRuntimeLibrary;
212 bool enableBufferInitialization;
222 options.bufferizeFunctionBoundaries =
true;
223 options.setFunctionBoundaryTypeConversion(LayoutMapOption::IdentityLayoutMap);
230 options.testAnalysisOnly =
true;
238 options.allowUnknownOps =
true;
244 return std::make_unique<
256 bool createSparseDeallocs,
bool enableRuntimeLibrary,
257 bool enableBufferInitialization,
unsigned vectorLength,
258 bool enableVLAVectorization,
bool enableSIMDIndex32,
bool enableGPULibgen,
261 return std::make_unique<
263 bufferizationOptions, sparsificationOptions, createSparseDeallocs,
264 enableRuntimeLibrary, enableBufferInitialization, vectorLength,
265 enableVLAVectorization, enableSIMDIndex32, enableGPULibgen, emitStrategy,
266 parallelizationStrategy);
static llvm::ManagedStatic< PassManagerOptions > options
Attributes are known-constant values of operations.
This class represents a pass manager that runs passes on either a specific operation type,...
void addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
Operation is the basic unit of execution within MLIR.
operand_range getOperands()
Returns an iterator on the underlying Value's.
result_range getResults()
Tensor types represent multi-dimensional arrays, and have two variants: RankedTensorType and Unranked...
This class provides an abstraction over the various different ranges of value types.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
BufferizationState provides information about the state of the IR during the bufferization process.
void denyOperation()
Deny the given ops.
A pass that lowers tensor ops to memref ops, regardless of whether they are dense or sparse.
SparsificationAndBufferizationPass(const bufferization::OneShotBufferizationOptions &bufferizationOptions, const SparsificationOptions &sparsificationOptions, bool createSparseDeallocs, bool enableRuntimeLibrary, bool enableBufferInitialization, unsigned vl, bool vla, bool index32, bool gpu, SparseEmitStrategy emitStrategy, SparseParallelizationStrategy parallelizationStrategy)
void runOnOperation() override
LogicalResult runDenseBufferization()
Bufferize all dense ops.
SparsificationAndBufferizationPass(const bufferization::OneShotBufferizationOptions &bufferizationOptions, const SparsificationOptions &sparsificationOptions, bool createSparseDeallocs, bool enableRuntimeLibrary, bool enableBufferInitialization)
BaseMemRefType getMemRefTypeWithStaticIdentityLayout(TensorType tensorType, Attribute memorySpace=nullptr)
Return a MemRef type with a static identity layout (i.e., no layout map).
llvm::LogicalResult bufferizeModuleOp(Operation *moduleOp, const OneShotBufferizationOptions &options, BufferizationState &state, BufferizationStatistics *statistics=nullptr)
Bufferize an ops nested ops that implement BufferizableOpInterface.
void removeBufferizationAttributesInModule(Operation *moduleOp)
Remove bufferization attributes on every FuncOp arguments in the SymbolTable op.
LogicalResult insertTensorCopies(Operation *op, const OneShotBufferizationOptions &options, const BufferizationState &bufferizationState, BufferizationStatistics *statistics=nullptr)
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
static bool containsSparseTensor(TypeRange types)
Return true if one of the given types is a sparse tensor type.
SparseTensorEncodingAttr getSparseTensorEncoding(Type type)
Convenience method to get a sparse encoding attribute from a type.
Include the generated interface declarations.
std::unique_ptr< Pass > createSparseVectorizationPass()
std::unique_ptr< Pass > createLowerSparseOpsToForeachPass()
std::unique_ptr< Pass > createSparseTensorCodegenPass()
std::unique_ptr< Pass > createSparseGPUCodegenPass()
std::unique_ptr< Pass > createSparseSpaceCollapsePass()
std::unique_ptr< Pass > createLoopInvariantCodeMotionPass()
Creates a loop invariant code motion pass that hoists loop invariant instructions out of the loop.
bufferization::OneShotBufferizationOptions getBufferizationOptionsForSparsification(bool analysisOnly)
std::unique_ptr< Pass > createSparseReinterpretMapPass()
std::unique_ptr< Pass > createSparseTensorConversionPass()
std::unique_ptr< Pass > createSparseBufferRewritePass()
std::unique_ptr< Pass > createSparsificationAndBufferizationPass()
SparseParallelizationStrategy
Defines a parallelization strategy.
SparseEmitStrategy
Defines a scope for reinterpret map pass.
std::unique_ptr< Pass > createPreSparsificationRewritePass()
std::unique_ptr< Pass > createLowerForeachToSCFPass()
std::unique_ptr< Pass > createLowerSparseIterationToSCFPass()
std::unique_ptr< Pass > createStageSparseOperationsPass()
std::unique_ptr< Pass > createSparsificationPass()
Options for the Sparsification pass.
SparseEmitStrategy sparseEmitStrategy
SparseParallelizationStrategy parallelizationStrategy
Options for BufferizableOpInterface-based bufferization.
bool testAnalysisOnly
If set to true, does not modify the IR apart from adding attributes (for checking the results of the ...
OpFilter opFilter
A filter that specifies which ops should be bufferized and which ops should be ignored.
Options for analysis-enabled bufferization.