MLIR  20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::sparse_tensor::SparseTensorStorage< P, C, V > Class Template Referencefinal

A memory-resident sparse tensor using a storage scheme based on per-level sparse/dense annotations. More...

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

+ Inheritance diagram for mlir::sparse_tensor::SparseTensorStorage< P, C, V >:

Public Member Functions

 SparseTensorStorage (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, SparseTensorCOO< V > *lvlCOO)
 Constructs a sparse tensor with the given encoding, and allocates overhead storage according to some simple heuristics. More...
 
 SparseTensorStorage (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, const intptr_t *lvlBufs)
 Constructs a sparse tensor with the given encoding, and initializes the contents from the level buffers. More...
 
 ~SparseTensorStorage () final=default
 
void getPositions (std::vector< P > **out, uint64_t lvl) final
 Partially specialize these getter methods based on template types. More...
 
void getCoordinates (std::vector< C > **out, uint64_t lvl) final
 
void getCoordinatesBuffer (std::vector< C > **out, uint64_t lvl) final
 
void getValues (std::vector< V > **out) final
 
void lexInsert (const uint64_t *lvlCoords, V val) final
 Partially specialize lexicographical insertions based on template types. More...
 
void expInsert (uint64_t *lvlCoords, V *values, bool *filled, uint64_t *added, uint64_t count, uint64_t expsz) final
 Partially specialize expanded insertions based on template types. More...
 
void endLexInsert () final
 Finalizes lexicographic insertions. More...
 
void sortInPlace ()
 Sort the unordered tensor in place, the method assumes that it is an unordered COO tensor. More...
 
- Public Member Functions inherited from mlir::sparse_tensor::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. 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...
 

Static Public Member Functions

static SparseTensorStorage< P, C, V > * newEmpty (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)
 Allocates a new empty sparse tensor. More...
 
static SparseTensorStorage< P, C, V > * newFromCOO (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, SparseTensorCOO< V > *lvlCOO)
 Allocates a new sparse tensor and initializes it from the given COO. More...
 
static SparseTensorStorage< P, C, V > * newFromBuffers (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, uint64_t srcRank, const intptr_t *buffers)
 Allocates a new sparse tensor and initialize it from the given buffers. More...
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::sparse_tensor::SparseTensorStorageBase
 SparseTensorStorageBase (const SparseTensorStorageBase &)=default
 
SparseTensorStorageBaseoperator= (const SparseTensorStorageBase &)=delete
 
- Protected Attributes inherited from mlir::sparse_tensor::SparseTensorStorageBase
const MapRef map
 
const bool allDense
 

Detailed Description

template<typename P, typename C, typename V>
class mlir::sparse_tensor::SparseTensorStorage< P, C, V >

A memory-resident sparse tensor using a storage scheme based on per-level sparse/dense annotations.

This data structure provides a bufferized form of a sparse tensor type. In contrast to generating setup methods for each differently annotated sparse tensor, this method provides a convenient "one-size-fits-all" solution that simply takes an input tensor and annotations to implement all required setup in a general manner.

Definition at line 195 of file Storage.h.

Constructor & Destructor Documentation

◆ SparseTensorStorage() [1/2]

template<typename P , typename C , typename V >
mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage ( 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,
SparseTensorCOO< V > *  lvlCOO 
)

◆ SparseTensorStorage() [2/2]

template<typename P , typename C , typename V >
mlir::sparse_tensor::SparseTensorStorage< P, C, V >::SparseTensorStorage ( 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,
const intptr_t *  lvlBufs 
)

Constructs a sparse tensor with the given encoding, and initializes the contents from the level buffers.

The constructor assumes that the data provided by lvlBufs can be directly used to interpret the result sparse tensor and performs no integrity test on the input data.

Definition at line 671 of file Storage.h.

References mlir::sparse_tensor::SparseTensorStorageBase::isCompressedLvl(), mlir::sparse_tensor::SparseTensorStorageBase::isDenseLvl(), mlir::sparse_tensor::SparseTensorStorageBase::isLooseCompressedLvl(), mlir::sparse_tensor::SparseTensorStorageBase::isNOutOfMLvl(), mlir::sparse_tensor::SparseTensorStorageBase::isSingletonLvl(), and mlir::sparse_tensor::SparseTensorStorageBase::isUniqueLvl().

◆ ~SparseTensorStorage()

template<typename P , typename C , typename V >
mlir::sparse_tensor::SparseTensorStorage< P, C, V >::~SparseTensorStorage ( )
finaldefault

Member Function Documentation

◆ endLexInsert()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::endLexInsert ( )
inlinefinalvirtual

Finalizes lexicographic insertions.

Implements mlir::sparse_tensor::SparseTensorStorageBase.

Definition at line 345 of file Storage.h.

References mlir::sparse_tensor::SparseTensorStorageBase::allDense.

◆ expInsert()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::expInsert ( uint64_t *  lvlCoords,
V *  values,
bool *  filled,
uint64_t *  added,
uint64_t  count,
uint64_t  expsz 
)
inlinefinal

Partially specialize expanded insertions based on template types.

Definition at line 315 of file Storage.h.

References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank(), and mlir::sparse_tensor::SparseTensorStorage< P, C, V >::lexInsert().

◆ getCoordinates()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::getCoordinates ( std::vector< C > **  out,
uint64_t  lvl 
)
inlinefinal

◆ getCoordinatesBuffer()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::getCoordinatesBuffer ( std::vector< C > **  out,
uint64_t  lvl 
)
inlinefinal

◆ getPositions()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::getPositions ( std::vector< P > **  out,
uint64_t  lvl 
)
inlinefinal

Partially specialize these getter methods based on template types.

Definition at line 250 of file Storage.h.

References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank().

◆ getValues()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::getValues ( std::vector< V > **  out)
inlinefinal

Definition at line 285 of file Storage.h.

◆ lexInsert()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::lexInsert ( const uint64_t *  lvlCoords,
val 
)
inlinefinal

◆ newEmpty()

template<typename P , typename C , typename V >
SparseTensorStorage< P, C, V > * mlir::sparse_tensor::SparseTensorStorage< P, C, V >::newEmpty ( 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 
)
static

Allocates a new empty sparse tensor.

Definition at line 580 of file Storage.h.

◆ newFromBuffers()

template<typename P , typename C , typename V >
SparseTensorStorage< P, C, V > * mlir::sparse_tensor::SparseTensorStorage< P, C, V >::newFromBuffers ( 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,
uint64_t  srcRank,
const intptr_t *  buffers 
)
static

Allocates a new sparse tensor and initialize it from the given buffers.

Definition at line 601 of file Storage.h.

◆ newFromCOO()

template<typename P , typename C , typename V >
SparseTensorStorage< P, C, V > * mlir::sparse_tensor::SparseTensorStorage< P, C, V >::newFromCOO ( 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,
SparseTensorCOO< V > *  lvlCOO 
)
static

Allocates a new sparse tensor and initializes it from the given COO.

Definition at line 590 of file Storage.h.

Referenced by mlir::sparse_tensor::SparseTensorReader::readSparseTensor().

◆ sortInPlace()

template<typename P , typename C , typename V >
void mlir::sparse_tensor::SparseTensorStorage< P, C, V >::sortInPlace ( )
inline

Sort the unordered tensor in place, the method assumes that it is an unordered COO tensor.

Definition at line 356 of file Storage.h.

References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank().


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