MLIR 22.0.0git
mlir::sparse_tensor::SparsificationAndBufferizationPass Class Reference

A pass that lowers tensor ops to memref ops, regardless of whether they are dense or sparse. More...

Inheritance diagram for mlir::sparse_tensor::SparsificationAndBufferizationPass:

Public Member Functions

 SparsificationAndBufferizationPass (const bufferization::OneShotBufferizationOptions &bufferizationOptions, const SparsificationOptions &sparsificationOptions, bool createSparseDeallocs, bool enableRuntimeLibrary, bool enableBufferInitialization)
 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)
LogicalResult runDenseBufferization ()
 Bufferize all dense ops.
void runOnOperation () override
 The polymorphic API that runs the pass over the currently held operation.
Public Member Functions inherited from mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >
 SparsificationAndBufferizationBase ()
SparsificationAndBufferizationBaseoperator= (const SparsificationAndBufferizationBase &)=delete
 ~SparsificationAndBufferizationBase ()=default
::llvm::StringRef getArgument () const override
 Return the command line argument used when registering this pass.
::llvm::StringRef getDescription () const override
 Return the command line description used when registering this pass.
::llvm::StringRef getName () const override
 Returns the derived pass name.
std::unique_ptr<::mlir::PassclonePass () const override
 A clone method to create a copy of this pass.
void getDependentDialects (::mlir::DialectRegistry &registry) const override
 Return the dialect that must be loaded in the context before this pass.
Public Member Functions inherited from mlir::OperationPass< ModuleOp >
 ~OperationPass () override=default
Public Member Functions inherited from mlir::Pass
virtual ~Pass ()=default
TypeID getTypeID () const
 Returns the unique identifier that corresponds to this pass.
const PassInfolookupPassInfo () const
 Returns the pass info for this pass, or null if unknown.
virtual void getDependentDialects (DialectRegistry &registry) const
 Register dependent dialects for the current pass.
std::optional< StringRef > getOpName () const
 Returns the name of the operation that this pass operates on, or std::nullopt if this is a generic OperationPass.
virtual LogicalResult initializeOptions (StringRef options, function_ref< LogicalResult(const Twine &)> errorHandler)
 Attempt to initialize the options of this pass from the given string.
void printAsTextualPipeline (raw_ostream &os, bool pretty=false)
 Prints out the pass in the textual representation of pipelines.
ArrayRef< Statistic * > getStatistics () const
 Returns the main statistics for this pass instance.
MutableArrayRef< Statistic * > getStatistics ()
const PassgetThreadingSibling () const
 Returns the thread sibling of this pass.
const PassgetThreadingSiblingOrThis () const
 Returns the thread sibling of this pass, or the pass itself it has no sibling.

Additional Inherited Members

Public Types inherited from mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >
using Base
Static Public Member Functions inherited from mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >
static constexpr ::llvm::StringLiteral getArgumentName ()
 Returns the command-line argument attached to this pass.
static constexpr ::llvm::StringLiteral getPassName ()
 Returns the derived pass name.
static bool classof (const ::mlir::Pass *pass)
 Support isa/dyn_cast functionality for the derived pass class.
Protected Member Functions inherited from mlir::OperationPass< ModuleOp >
 OperationPass (TypeID passID)
OperationPassoperator= (const OperationPass &)=delete
bool canScheduleOn (RegisteredOperationName opName) const final
 Indicate if the current pass can be scheduled on the given operation type.
ModuleOp getOperation ()
 Return the current operation being transformed.
AnalysisT & getAnalysis ()
 Query an analysis for the current operation of the specific derived operation type.
Protected Member Functions inherited from mlir::Pass
 Pass (TypeID passID, std::optional< StringRef > opName=std::nullopt)
 Pass (const Pass &other)
Passoperator= (const Pass &)=delete
 Pass (Pass &&)=delete
Passoperator= (Pass &&)=delete
detail::PassExecutionStategetPassState ()
 Returns the current pass state.
MLIRContextgetContext ()
 Return the MLIR context for the current operation being transformed.
virtual LogicalResult initialize (MLIRContext *context)
 Initialize any complex state necessary for running this pass.
LogicalResult runPipeline (OpPassManager &pipeline, Operation *op)
 Schedule an arbitrary pass pipeline on the provided operation.
std::unique_ptr< Passclone () const
 A clone method to create a copy of this pass.
OperationgetOperation ()
 Return the current operation being transformed.
void signalPassFailure ()
 Signal that some invariant was broken when running.
template<typename AnalysisT>
AnalysisT & getAnalysis ()
 Query an analysis for the current ir unit.
template<typename AnalysisT, typename OpT>
AnalysisT & getAnalysis ()
 Query an analysis for the current ir unit of a specific derived operation type.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedAnalysis ()
 Query a cached instance of an analysis for the current ir unit if one exists.
void markAllAnalysesPreserved ()
 Mark all analyses as preserved.
template<typename... AnalysesT>
void markAnalysesPreserved ()
 Mark the provided analyses as preserved.
void markAnalysesPreserved (TypeID id)
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis (Operation *parent)
 Returns the analysis for the given parent operation if it exists.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedParentAnalysis ()
 Returns the analysis for the parent operation if it exists.
template<typename AnalysisT>
std::optional< std::reference_wrapper< AnalysisT > > getCachedChildAnalysis (Operation *child)
 Returns the analysis for the given child operation if it exists.
template<typename AnalysisT>
AnalysisT & getChildAnalysis (Operation *child)
 Returns the analysis for the given child operation, or creates it if it doesn't exist.
template<typename AnalysisT, typename OpTy>
AnalysisT & getChildAnalysis (OpTy child)
 Returns the analysis for the given child operation of specific derived operation type, or creates it if it doesn't exist.
AnalysisManager getAnalysisManager ()
 Returns the current analysis manager.
void copyOptionValuesFrom (const Pass *other)
 Copy the option values from 'other', which is another instance of this pass.
Static Protected Member Functions inherited from mlir::OperationPass< ModuleOp >
static bool classof (const Pass *pass)
 Support isa/dyn_cast functionality.
Protected Attributes inherited from mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >
::mlir::Pass::Option< int32_t > vectorLength
::mlir::Pass::Option< boolenableVLAVectorization
::mlir::Pass::Option< boolenableSIMDIndex32
::mlir::Pass::Option< boolenableGPULibgen
::mlir::Pass::Option< mlir::SparseEmitStrategysparseEmitStrategy
::mlir::Pass::Option< mlir::SparseParallelizationStrategyparallelization

Detailed Description

A pass that lowers tensor ops to memref ops, regardless of whether they are dense or sparse.

One-Shot Analysis is used to detect RaW conflicts and to insert buffer copies of the tensor level (insertTensorCopies). Afterwards, the lowering of tensor ops to memref ops follows a different code path depending on whether the op is sparse or dense:

  • Sparse tensor ops are lowered through Sparsification and follow-up pass that lowers sparse_tensor dialect ops.
  • Dense tensor ops are lowered through BufferizableOpInterface implementations.

Definition at line 59 of file SparsificationAndBufferizationPass.cpp.

Constructor & Destructor Documentation

◆ SparsificationAndBufferizationPass() [1/2]

mlir::sparse_tensor::SparsificationAndBufferizationPass::SparsificationAndBufferizationPass ( const bufferization::OneShotBufferizationOptions & bufferizationOptions,
const SparsificationOptions & sparsificationOptions,
bool createSparseDeallocs,
bool enableRuntimeLibrary,
bool enableBufferInitialization )
inline

Definition at line 64 of file SparsificationAndBufferizationPass.cpp.

◆ SparsificationAndBufferizationPass() [2/2]

Member Function Documentation

◆ runDenseBufferization()

LogicalResult mlir::sparse_tensor::SparsificationAndBufferizationPass::runDenseBufferization ( )
inline

Bufferize all dense ops.

This assumes that no further analysis is needed and that all required buffer copies were already inserted by insertTensorCopies in the form of bufferization.alloc_tensor ops.

Definition at line 99 of file SparsificationAndBufferizationPass.cpp.

References mlir::bufferization::bufferizeModuleOp(), mlir::sparse_tensor::containsSparseTensor(), mlir::Operation::getOperands(), mlir::OperationPass< ModuleOp >::getOperation(), mlir::Operation::getResults(), mlir::bufferization::removeBufferizationAttributesInModule(), success(), and TypeRange.

Referenced by runOnOperation().

◆ runOnOperation()

void mlir::sparse_tensor::SparsificationAndBufferizationPass::runOnOperation ( )
inlineoverridevirtual

The polymorphic API that runs the pass over the currently held operation.

Implements mlir::Pass.

Definition at line 126 of file SparsificationAndBufferizationPass.cpp.

References mlir::OpPassManager::addNestedPass(), mlir::OpPassManager::addPass(), mlir::bufferization::createEmptyTensorToAllocTensorPass(), mlir::createLoopInvariantCodeMotionPass(), mlir::createLowerForeachToSCFPass(), mlir::createLowerSparseIterationToSCFPass(), mlir::createLowerSparseOpsToForeachPass(), mlir::createPreSparsificationRewritePass(), mlir::createSparseBufferRewritePass(), mlir::createSparseGPUCodegenPass(), mlir::createSparseReinterpretMapPass(), mlir::createSparseSpaceCollapsePass(), mlir::createSparseTensorCodegenPass(), mlir::createSparseTensorConversionPass(), mlir::createSparseVectorizationPass(), mlir::createSparsificationPass(), mlir::createStageSparseOperationsPass(), mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::enableGPULibgen, mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::enableSIMDIndex32, mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::enableVLAVectorization, mlir::OperationPass< ModuleOp >::getOperation(), mlir::bufferization::insertTensorCopies(), mlir::kAll, mlir::kExceptGeneric, mlir::kSparseIterator, mlir::Pass::OpPassManager, mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::parallelization, runDenseBufferization(), mlir::Pass::runPipeline(), mlir::Pass::signalPassFailure(), mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::sparseEmitStrategy, and mlir::impl::SparsificationAndBufferizationBase< SparsificationAndBufferizationPass >::vectorLength.


The documentation for this class was generated from the following file: