MLIR
20.0.0git
|
A memory-resident sparse tensor using a storage scheme based on per-level sparse/dense annotations. More...
#include "mlir/ExecutionEngine/SparseTensor/Storage.h"
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 | |
SparseTensorStorageBase & | operator= (const SparseTensorStorageBase &)=delete |
Protected Attributes inherited from mlir::sparse_tensor::SparseTensorStorageBase | |
const MapRef | map |
const bool | allDense |
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.
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 | ||
) |
Constructs a sparse tensor with the given encoding, and allocates overhead storage according to some simple heuristics.
When lvlCOO is set, the sparse tensor initializes with the contents from that data structure. Otherwise, an empty sparse tensor results.
Definition at line 617 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::allDense, mlir::sparse_tensor::detail::checkedMul(), mlir::sparse_tensor::SparseTensorCOO< V >::getElements(), mlir::sparse_tensor::SparseTensorCOO< V >::getRank(), 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::SparseTensorCOO< V >::sort().
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().
|
finaldefault |
|
inlinefinalvirtual |
Finalizes lexicographic insertions.
Implements mlir::sparse_tensor::SparseTensorStorageBase.
Definition at line 345 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::allDense.
|
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().
|
inlinefinal |
Definition at line 255 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank().
|
inlinefinal |
Definition at line 260 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank().
|
inlinefinal |
Partially specialize these getter methods based on template types.
Definition at line 250 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank().
|
inlinefinal |
|
inlinefinal |
Partially specialize lexicographical insertions based on template types.
Definition at line 291 of file Storage.h.
References mlir::sparse_tensor::SparseTensorStorageBase::allDense, mlir::sparse_tensor::SparseTensorStorageBase::getLvlRank(), and mlir::sparse_tensor::SparseTensorStorageBase::getLvlSize().
Referenced by mlir::sparse_tensor::SparseTensorStorage< P, C, V >::expInsert().
|
static |
|
static |
|
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().
|
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().