MLIR
20.0.0git
|
Provides methods to access fields of a sparse tensor with the given encoding. More...
#include "mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h"
Public Member Functions | |
StorageLayout (const SparseTensorType &stt) | |
StorageLayout (SparseTensorEncodingAttr enc) | |
void | foreachField (llvm::function_ref< bool(FieldIndex, SparseTensorFieldKind, Level, LevelType)>) const |
For each field that will be allocated for the given sparse tensor encoding, calls the callback with the corresponding field index, field kind, level, and level-type (the last two are only for level memrefs). More... | |
FieldIndex | getMemRefFieldIndex (SparseTensorFieldKind kind, std::optional< Level > lvl) const |
Gets the field index for required field. More... | |
unsigned | getNumFields () const |
Gets the total number of fields for the given sparse tensor encoding. More... | |
unsigned | getNumDataFields () const |
Gets the total number of data fields (coordinate arrays, position arrays, and a value array) for the given sparse tensor encoding. More... | |
std::pair< FieldIndex, unsigned > | getFieldIndexAndStride (SparseTensorFieldKind kind, std::optional< Level > lvl) const |
Provides methods to access fields of a sparse tensor with the given encoding.
Definition at line 114 of file SparseTensorStorageLayout.h.
|
inlineexplicit |
Definition at line 116 of file SparseTensorStorageLayout.h.
|
inlineexplicit |
Definition at line 118 of file SparseTensorStorageLayout.h.
void StorageLayout::foreachField | ( | llvm::function_ref< bool(FieldIndex, SparseTensorFieldKind, Level, LevelType)> | callback | ) | const |
For each field that will be allocated for the given sparse tensor encoding, calls the callback with the corresponding field index, field kind, level, and level-type (the last two are only for level memrefs).
The field index always starts with zero and increments by one between each callback invocation. Ideally, all other methods should rely on this function to query a sparse tensor fields instead of relying on ad-hoc index computation.
Definition at line 102 of file SparseTensorDialect.cpp.
References mlir::sparse_tensor::CrdMemRef, mlir::sparse_tensor::isWithCrdLT(), mlir::sparse_tensor::isWithPosLT(), kDataFieldStartingIdx, kInvalidLevel, mlir::sparse_tensor::PosMemRef, mlir::sparse_tensor::StorageSpec, mlir::sparse_tensor::Undef, and mlir::sparse_tensor::ValMemRef.
Referenced by mlir::sparse_tensor::foreachFieldAndTypeInSparseTensor(), mlir::sparse_tensor::foreachFieldInSparseTensor(), getFieldIndexAndStride(), getNumDataFields(), getNumFields(), and verifyPackUnPack().
std::pair< FieldIndex, unsigned > StorageLayout::getFieldIndexAndStride | ( | SparseTensorFieldKind | kind, |
std::optional< Level > | lvl | ||
) | const |
Definition at line 209 of file SparseTensorDialect.cpp.
References mlir::sparse_tensor::CrdMemRef, foreachField(), kInvalidFieldIndex, and mlir::sparse_tensor::ValMemRef.
Referenced by mlir::sparse_tensor::SparseTensorDescriptorImpl< ValueArrayRef >::getCrdMemRefIndexAndStride(), and getMemRefFieldIndex().
|
inline |
Gets the field index for required field.
Definition at line 136 of file SparseTensorStorageLayout.h.
References getFieldIndexAndStride().
Referenced by mlir::sparse_tensor::SparseTensorDescriptorImpl< ValueArrayRef >::getMemRefFieldIndex(), and SpecifierGetterSetterOpConverter< Base, SourceOp >::matchAndRewrite().
unsigned StorageLayout::getNumDataFields | ( | ) | const |
Gets the total number of data fields (coordinate arrays, position arrays, and a value array) for the given sparse tensor encoding.
Definition at line 195 of file SparseTensorDialect.cpp.
References foreachField(), getNumFields(), and kDataFieldStartingIdx.
Referenced by mlir::sparse_tensor::getNumDataFieldsFromEncoding(), and verifyPackUnPack().
unsigned StorageLayout::getNumFields | ( | ) | const |
Gets the total number of fields for the given sparse tensor encoding.
Definition at line 185 of file SparseTensorDialect.cpp.
References foreachField().
Referenced by getNumDataFields(), mlir::sparse_tensor::getNumFieldsFromEncoding(), and mlir::sparse_tensor::SparseTensorDescriptorImpl< ValueArrayRef >::SparseTensorDescriptorImpl().