35 #define GEN_PASS_DEF_SPARSIFICATIONANDBUFFERIZATION
36 #include "mlir/Dialect/SparseTensor/Transforms/Passes.h.inc"
38 namespace sparse_tensor {
61 :
public impl::SparsificationAndBufferizationBase<
62 SparsificationAndBufferizationPass> {
67 bool createSparseDeallocs,
bool enableRuntimeLibrary,
68 bool enableBufferInitialization,
unsigned vectorLength,
69 bool enableVLAVectorization,
bool enableSIMDIndex32,
bool enableGPULibgen)
70 : bufferizationOptions(bufferizationOptions),
71 sparsificationOptions(sparsificationOptions),
72 createSparseDeallocs(createSparseDeallocs),
73 enableRuntimeLibrary(enableRuntimeLibrary),
74 enableBufferInitialization(enableBufferInitialization),
75 vectorLength(vectorLength),
76 enableVLAVectorization(enableVLAVectorization),
77 enableSIMDIndex32(enableSIMDIndex32), enableGPULibgen(enableGPULibgen) {
91 if (
auto funcOp = dyn_cast<func::FuncOp>(op)) {
92 FunctionType funcType = funcOp.getFunctionType();
115 if (
failed(runPipeline(pm, getOperation())))
116 return signalPassFailure();
130 bufferizationOptions)))
131 return signalPassFailure();
155 if (vectorLength > 0) {
157 vectorLength, enableVLAVectorization, enableSIMDIndex32));
159 if (enableRuntimeLibrary) {
163 enableBufferInitialization));
166 if (
failed(runPipeline(pm, getOperation())))
167 return signalPassFailure();
178 bool createSparseDeallocs;
179 bool enableRuntimeLibrary;
180 bool enableBufferInitialization;
181 unsigned vectorLength;
182 bool enableVLAVectorization;
183 bool enableSIMDIndex32;
184 bool enableGPULibgen;
194 options.bufferizeFunctionBoundaries =
true;
195 options.setFunctionBoundaryTypeConversion(LayoutMapOption::IdentityLayoutMap);
199 cast<TensorType>(value.
getType()), memorySpace);
202 options.testAnalysisOnly =
true;
210 options.allowUnknownOps =
true;
231 bool createSparseDeallocs,
bool enableRuntimeLibrary,
232 bool enableBufferInitialization,
unsigned vectorLength,
233 bool enableVLAVectorization,
bool enableSIMDIndex32,
bool enableGPULibgen) {
234 return std::make_unique<
236 bufferizationOptions, sparsificationOptions, createSparseDeallocs,
237 enableRuntimeLibrary, enableBufferInitialization, vectorLength,
238 enableVLAVectorization, enableSIMDIndex32, enableGPULibgen);
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()
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...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
void denyOperation()
Deny the given ops.
A pass that lowers tensor ops to memref ops, regardless of whether they are dense or sparse.
void runOnOperation() override
LogicalResult runDenseBufferization()
Bufferize all dense ops.
SparsificationAndBufferizationPass(const bufferization::OneShotBufferizationOptions &bufferizationOptions, const SparsificationOptions &sparsificationOptions, bool createSparseDeallocs, bool enableRuntimeLibrary, bool enableBufferInitialization, unsigned vectorLength, bool enableVLAVectorization, bool enableSIMDIndex32, bool enableGPULibgen)
BaseMemRefType getMemRefTypeWithStaticIdentityLayout(TensorType tensorType, Attribute memorySpace=nullptr)
Return a MemRef type with a static identity layout (i.e., no layout map).
LogicalResult insertTensorCopies(Operation *op, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Resolve RaW and other conflicts by inserting bufferization.alloc_tensor ops.
void removeBufferizationAttributesInModule(ModuleOp moduleOp)
Remove bufferization attributes on every FuncOp arguments in the ModuleOp.
std::unique_ptr< Pass > createEmptyTensorToAllocTensorPass()
Create a pass that rewrites tensor.empty to bufferization.alloc_tensor.
LogicalResult bufferizeModuleOp(ModuleOp moduleOp, const OneShotBufferizationOptions &options, BufferizationStatistics *statistics=nullptr)
Bufferize op and its nested ops that implement BufferizableOpInterface.
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()
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
std::unique_ptr< Pass > createLowerSparseOpsToForeachPass()
std::unique_ptr< Pass > createSparseTensorCodegenPass()
std::unique_ptr< Pass > createSparseGPUCodegenPass()
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()
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
std::unique_ptr< Pass > createPreSparsificationRewritePass()
std::unique_ptr< Pass > createLowerForeachToSCFPass()
std::unique_ptr< Pass > createStageSparseOperationsPass()
std::unique_ptr< Pass > createSparsificationPass()
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.
Options for the Sparsification pass.
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.