MLIR  19.0.0git
Public Member Functions | List of all members
mlir::sparse_tensor::SparseTensorCOO< V > Class Template Referencefinal

A memory-resident sparse tensor in coordinate-scheme representation (a collection of Elements). More...

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

Public Member Functions

 SparseTensorCOO (const std::vector< uint64_t > &dimSizes, uint64_t capacity=0)
 Constructs a new coordinate-scheme sparse tensor with the given sizes and an optional initial storage capacity. More...
 
 SparseTensorCOO (uint64_t dimRank, const uint64_t *dimSizes, uint64_t capacity=0)
 Constructs a new coordinate-scheme sparse tensor with the given sizes and an optional initial storage capacity. More...
 
uint64_t getRank () const
 Gets the dimension-rank of the tensor. More...
 
const std::vector< uint64_t > & getDimSizes () const
 Gets the dimension-sizes array. More...
 
const std::vector< Element< V > > & getElements () const
 Gets the elements array. More...
 
ElementLT< V > getElementLT () const
 Returns the operator< closure object for the COO's element type. More...
 
void add (const std::vector< uint64_t > &dimCoords, V val)
 Adds an element to the tensor. More...
 
void sort ()
 Sorts elements lexicographically by coordinates. More...
 

Detailed Description

template<typename V>
class mlir::sparse_tensor::SparseTensorCOO< V >

A memory-resident sparse tensor in coordinate-scheme representation (a collection of Elements).

This data structure is used as an intermediate representation, e.g., for reading sparse tensors from external formats into memory.

Definition at line 66 of file COO.h.

Constructor & Destructor Documentation

◆ SparseTensorCOO() [1/2]

template<typename V >
mlir::sparse_tensor::SparseTensorCOO< V >::SparseTensorCOO ( const std::vector< uint64_t > &  dimSizes,
uint64_t  capacity = 0 
)
inlineexplicit

Constructs a new coordinate-scheme sparse tensor with the given sizes and an optional initial storage capacity.

Definition at line 70 of file COO.h.

◆ SparseTensorCOO() [2/2]

template<typename V >
mlir::sparse_tensor::SparseTensorCOO< V >::SparseTensorCOO ( uint64_t  dimRank,
const uint64_t *  dimSizes,
uint64_t  capacity = 0 
)
inlineexplicit

Constructs a new coordinate-scheme sparse tensor with the given sizes and an optional initial storage capacity.

The size of the dimSizes array is determined by dimRank.

Definition at line 77 of file COO.h.

Member Function Documentation

◆ add()

template<typename V >
void mlir::sparse_tensor::SparseTensorCOO< V >::add ( const std::vector< uint64_t > &  dimCoords,
val 
)
inline

Adds an element to the tensor.

Definition at line 102 of file COO.h.

References mlir::sparse_tensor::SparseTensorCOO< V >::getElementLT(), and mlir::sparse_tensor::SparseTensorCOO< V >::getRank().

◆ getDimSizes()

template<typename V >
const std::vector<uint64_t>& mlir::sparse_tensor::SparseTensorCOO< V >::getDimSizes ( ) const
inline

Gets the dimension-sizes array.

Definition at line 93 of file COO.h.

◆ getElementLT()

template<typename V >
ElementLT<V> mlir::sparse_tensor::SparseTensorCOO< V >::getElementLT ( ) const
inline

Returns the operator< closure object for the COO's element type.

Definition at line 99 of file COO.h.

References mlir::sparse_tensor::SparseTensorCOO< V >::getRank().

Referenced by mlir::sparse_tensor::SparseTensorCOO< V >::add(), and mlir::sparse_tensor::SparseTensorCOO< V >::sort().

◆ getElements()

template<typename V >
const std::vector<Element<V> >& mlir::sparse_tensor::SparseTensorCOO< V >::getElements ( ) const
inline

Gets the elements array.

Definition at line 96 of file COO.h.

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

◆ getRank()

template<typename V >
uint64_t mlir::sparse_tensor::SparseTensorCOO< V >::getRank ( ) const
inline

◆ sort()

template<typename V >
void mlir::sparse_tensor::SparseTensorCOO< V >::sort ( )
inline

Sorts elements lexicographically by coordinates.

If a coordinate is mapped to multiple values, then the relative order of those values is unspecified.

Definition at line 133 of file COO.h.

References mlir::sparse_tensor::SparseTensorCOO< V >::getElementLT().

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


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