MLIR  19.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mlir::sparse_tensor::SparseTensorStorageBase Class Referenceabstract

Abstract base class for SparseTensorStorage<P,C,V>. More...

#include "mlir/ExecutionEngine/SparseTensor/Storage.h"

+ Inheritance diagram for mlir::sparse_tensor::SparseTensorStorageBase:

Public Member Functions

 SparseTensorStorageBase (uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, const uint64_t *lvlSizes, const LevelType *lvlTypes, const uint64_t *dim2lvl, const uint64_t *lvl2dim)
 Constructs a new sparse-tensor storage object with the given encoding. More...
 
virtual ~SparseTensorStorageBase ()=default
 
uint64_t getDimRank () const
 Gets the number of tensor-dimensions. More...
 
uint64_t getLvlRank () const
 Gets the number of storage-levels. More...
 
const std::vector< uint64_t > & getDimSizes () const
 Gets the tensor-dimension sizes array. More...
 
uint64_t getDimSize (uint64_t d) const
 Safely looks up the size of the given tensor-dimension. More...
 
const std::vector< uint64_t > & getLvlSizes () const
 Gets the storage-level sizes array. More...
 
uint64_t getLvlSize (uint64_t l) const
 Safely looks up the size of the given storage-level. More...
 
const std::vector< LevelType > & getLvlTypes () const
 Gets the level-types array. More...
 
LevelType getLvlType (uint64_t l) const
 Safely looks up the type of the given level. More...
 
bool isDenseLvl (uint64_t l) const
 Safely checks if the level uses dense storage. More...
 
bool isCompressedLvl (uint64_t l) const
 Safely checks if the level uses compressed storage. More...
 
bool isLooseCompressedLvl (uint64_t l) const
 Safely checks if the level uses loose compressed storage. More...
 
bool isSingletonLvl (uint64_t l) const
 Safely checks if the level uses singleton storage. More...
 
bool isNOutOfMLvl (uint64_t l) const
 Safely checks if the level uses n out of m storage. More...
 
bool isOrderedLvl (uint64_t l) const
 Safely checks if the level is ordered. More...
 
bool isUniqueLvl (uint64_t l) const
 Safely checks if the level is unique. More...
 
virtual void endLexInsert ()=0
 Finalizes lexicographic insertions. More...
 

Protected Member Functions

 SparseTensorStorageBase (const SparseTensorStorageBase &)=default
 
SparseTensorStorageBaseoperator= (const SparseTensorStorageBase &)=delete
 

Protected Attributes

const MapRef map
 
const bool allDense
 

Detailed Description

Abstract base class for SparseTensorStorage<P,C,V>.

This class takes responsibility for all the <P,C,V>-independent aspects of the tensor (e.g., sizes, sparsity, mapping). In addition, we use function overloading to implement "partial" method specialization, which the C-API relies on to catch type errors arising from our use of opaque pointers.

Because this class forms a bridge between the denotational semantics of "tensors" and the operational semantics of how we store and compute with them, it also distinguishes between two different coordinate spaces (and their associated rank, sizes, etc). Denotationally, we have the dimensions of the tensor represented by this object. Operationally, we have the levels of the storage representation itself.

The size of an axis is the cardinality of possible coordinate values along that axis (regardless of which coordinates have stored element values). As such, each size must be non-zero since if any axis has size-zero then the whole tensor would have trivial storage (since there are no possible coordinates). Thus we use the plural term sizes for a collection of non-zero cardinalities, and use this term whenever referring to run-time cardinalities. Whereas we use the term shape for a collection of compile-time cardinalities, where zero is used to indicate cardinalities which are dynamic (i.e., unknown/unspecified at compile-time). At run-time, these dynamic cardinalities will be inferred from or checked against sizes otherwise specified. Thus, dynamic cardinalities always have an "immutable but unknown" value; so the term "dynamic" should not be taken to indicate run-time mutability.

Definition at line 63 of file Storage.h.

Constructor & Destructor Documentation

◆ SparseTensorStorageBase() [1/2]

mlir::sparse_tensor::SparseTensorStorageBase::SparseTensorStorageBase ( const SparseTensorStorageBase )
protecteddefault

◆ SparseTensorStorageBase() [2/2]

SparseTensorStorageBase::SparseTensorStorageBase ( uint64_t  dimRank,
const uint64_t *  dimSizes,
uint64_t  lvlRank,
const uint64_t *  lvlSizes,
const LevelType lvlTypes,
const uint64_t *  dim2lvl,
const uint64_t *  lvl2dim 
)

Constructs a new sparse-tensor storage object with the given encoding.

Definition at line 27 of file Storage.cpp.

References isCompressedLvl(), isDenseLvl(), isLooseCompressedLvl(), isNOutOfMLvl(), and isSingletonLvl().

◆ ~SparseTensorStorageBase()

virtual mlir::sparse_tensor::SparseTensorStorageBase::~SparseTensorStorageBase ( )
virtualdefault

Member Function Documentation

◆ endLexInsert()

virtual void mlir::sparse_tensor::SparseTensorStorageBase::endLexInsert ( )
pure virtual

Finalizes lexicographic insertions.

Implemented in mlir::sparse_tensor::SparseTensorStorage< P, C, V >.

◆ getDimRank()

uint64_t mlir::sparse_tensor::SparseTensorStorageBase::getDimRank ( ) const
inline

Gets the number of tensor-dimensions.

Definition at line 77 of file Storage.h.

Referenced by getDimSize().

◆ getDimSize()

uint64_t mlir::sparse_tensor::SparseTensorStorageBase::getDimSize ( uint64_t  d) const
inline

Safely looks up the size of the given tensor-dimension.

Definition at line 86 of file Storage.h.

References getDimRank().

◆ getDimSizes()

const std::vector<uint64_t>& mlir::sparse_tensor::SparseTensorStorageBase::getDimSizes ( ) const
inline

Gets the tensor-dimension sizes array.

Definition at line 83 of file Storage.h.

◆ getLvlRank()

uint64_t mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank ( ) const
inline

◆ getLvlSize()

uint64_t mlir::sparse_tensor::SparseTensorStorageBase::getLvlSize ( uint64_t  l) const
inline

Safely looks up the size of the given storage-level.

Definition at line 95 of file Storage.h.

References getLvlRank().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::lexInsert().

◆ getLvlSizes()

const std::vector<uint64_t>& mlir::sparse_tensor::SparseTensorStorageBase::getLvlSizes ( ) const
inline

Gets the storage-level sizes array.

Definition at line 92 of file Storage.h.

◆ getLvlType()

LevelType mlir::sparse_tensor::SparseTensorStorageBase::getLvlType ( uint64_t  l) const
inline

Safely looks up the type of the given level.

Definition at line 104 of file Storage.h.

References getLvlRank().

Referenced by isCompressedLvl(), isDenseLvl(), isLooseCompressedLvl(), isNOutOfMLvl(), isOrderedLvl(), isSingletonLvl(), and isUniqueLvl().

◆ getLvlTypes()

const std::vector<LevelType>& mlir::sparse_tensor::SparseTensorStorageBase::getLvlTypes ( ) const
inline

Gets the level-types array.

Definition at line 101 of file Storage.h.

◆ isCompressedLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isCompressedLvl ( uint64_t  l) const
inline

Safely checks if the level uses compressed storage.

Definition at line 113 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isCompressedLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage(), and SparseTensorStorageBase().

◆ isDenseLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isDenseLvl ( uint64_t  l) const
inline

Safely checks if the level uses dense storage.

Definition at line 110 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isDenseLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage(), and SparseTensorStorageBase().

◆ isLooseCompressedLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isLooseCompressedLvl ( uint64_t  l) const
inline

Safely checks if the level uses loose compressed storage.

Definition at line 118 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isLooseCompressedLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage(), and SparseTensorStorageBase().

◆ isNOutOfMLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isNOutOfMLvl ( uint64_t  l) const
inline

Safely checks if the level uses n out of m storage.

Definition at line 126 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isNOutOfMLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage(), and SparseTensorStorageBase().

◆ isOrderedLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isOrderedLvl ( uint64_t  l) const
inline

Safely checks if the level is ordered.

Definition at line 129 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isOrderedLT().

◆ isSingletonLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isSingletonLvl ( uint64_t  l) const
inline

Safely checks if the level uses singleton storage.

Definition at line 123 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isSingletonLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage(), and SparseTensorStorageBase().

◆ isUniqueLvl()

bool mlir::sparse_tensor::SparseTensorStorageBase::isUniqueLvl ( uint64_t  l) const
inline

Safely checks if the level is unique.

Definition at line 132 of file Storage.h.

References getLvlType(), and mlir::sparse_tensor::isUniqueLT().

Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage().

◆ operator=()

SparseTensorStorageBase& mlir::sparse_tensor::SparseTensorStorageBase::operator= ( const SparseTensorStorageBase )
protecteddelete

Member Data Documentation

◆ allDense

const bool mlir::sparse_tensor::SparseTensorStorageBase::allDense
protected

◆ map

const MapRef mlir::sparse_tensor::SparseTensorStorageBase::map
protected

Definition at line 177 of file Storage.h.


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