MLIR 22.0.0git
mlir::sparse_tensor::LevelType Struct Reference

This enum defines all the sparse representations supportable by the SparseTensor dialect. More...

#include "mlir/Dialect/SparseTensor/IR/Enums.h"

Public Member Functions

constexpr LevelType (uint64_t bits)
 Explicit conversion from uint64_t.
 LevelType (LevelFormat f)
 Constructs a LevelType with the given format using all default properties.
 operator uint64_t () const
 Converts to uint64_t.
bool operator== (const LevelType lhs) const
bool operator!= (const LevelType lhs) const
LevelType stripStorageIrrelevantProperties () const
constexpr uint64_t getN () const
 Get N of NOutOfM level type.
constexpr uint64_t getM () const
 Get M of NOutOfM level type.
constexpr LevelFormat getLvlFmt () const
 Get the LevelFormat of the LevelType.
template<LevelFormat... fmt>
constexpr bool isa () const
 Check if the LevelType is in the LevelFormat.
template<LevelPropNonDefault p>
constexpr bool isa () const
 Check if the LevelType has the properties.
constexpr bool hasSparseSemantic () const
 Check if the LevelType is considered to be sparse.
constexpr bool hasDenseSemantic () const
 Check if the LevelType is considered to be dense-like.
constexpr bool isWithPosLT () const
 Check if the LevelType needs positions array.
constexpr bool isWithCrdLT () const
 Check if the LevelType needs coordinates array.
constexpr unsigned getNumBuffer () const
std::string toMLIRString () const

Static Public Member Functions

static constexpr bool isValidLvlBits (uint64_t lvlBits)
 Check that the LevelType contains a valid (possibly undefined) value.
static std::optional< LevelTypebuildLvlType (LevelFormat lf, const std::vector< LevelPropNonDefault > &properties, uint64_t n=0, uint64_t m=0)
 Convert a LevelFormat to its corresponding LevelType with the given properties.
static std::optional< LevelTypebuildLvlType (LevelFormat lf, bool ordered, bool unique, uint64_t n=0, uint64_t m=0)

Detailed Description

This enum defines all the sparse representations supportable by the SparseTensor dialect.

We use a lightweight encoding to encode the "format" per se (dense, compressed, singleton, loose_compressed, n-out-of-m), the "properties" (ordered, unique) as well as n and m when the format is NOutOfM. The encoding is chosen for performance of the runtime library, and thus may change in future versions; consequently, client code should use the predicate functions defined below, rather than relying on knowledge about the particular binary encoding.

The Undef "format" is a special value used internally for cases where we need to store an undefined or indeterminate LevelType. It should not be used externally, since it does not indicate an actual/representable format.

Definition at line 238 of file Enums.h.

Constructor & Destructor Documentation

◆ LevelType() [1/2]

mlir::sparse_tensor::LevelType::LevelType ( uint64_t bits)
inlineexplicitconstexpr

Explicit conversion from uint64_t.

Definition at line 282 of file Enums.h.

References isValidLvlBits().

Referenced by buildLvlType(), operator!=(), operator==(), and stripStorageIrrelevantProperties().

◆ LevelType() [2/2]

mlir::sparse_tensor::LevelType::LevelType ( LevelFormat f)
inline

Constructs a LevelType with the given format using all default properties.

Definition at line 287 of file Enums.h.

References isa(), and isValidLvlBits().

Member Function Documentation

◆ buildLvlType() [1/2]

std::optional< LevelType > mlir::sparse_tensor::LevelType::buildLvlType ( LevelFormat lf,
bool ordered,
bool unique,
uint64_t n = 0,
uint64_t m = 0 )
inlinestatic

◆ buildLvlType() [2/2]

std::optional< LevelType > mlir::sparse_tensor::LevelType::buildLvlType ( LevelFormat lf,
const std::vector< LevelPropNonDefault > & properties,
uint64_t n = 0,
uint64_t m = 0 )
inlinestatic

Convert a LevelFormat to its corresponding LevelType with the given properties.

Returns std::nullopt when the properties are not applicable for the input level format.

Definition at line 257 of file Enums.h.

References isValidLvlBits(), and LevelType().

Referenced by mlir::sparse_tensor::buildLevelType(), mlir::sparse_tensor::buildLevelType(), and buildLvlType().

◆ getLvlFmt()

LevelFormat mlir::sparse_tensor::LevelType::getLvlFmt ( ) const
inlineconstexpr

◆ getM()

uint64_t mlir::sparse_tensor::LevelType::getM ( ) const
inlineconstexpr

Get M of NOutOfM level type.

Definition at line 314 of file Enums.h.

References isa().

Referenced by mlir::sparse_tensor::getM(), mlir::sparse_tensor::isValidNOutOfMLT(), and toMLIRString().

◆ getN()

uint64_t mlir::sparse_tensor::LevelType::getN ( ) const
inlineconstexpr

Get N of NOutOfM level type.

Definition at line 308 of file Enums.h.

References isa().

Referenced by mlir::sparse_tensor::getN(), mlir::sparse_tensor::isValidNOutOfMLT(), and toMLIRString().

◆ getNumBuffer()

unsigned mlir::sparse_tensor::LevelType::getNumBuffer ( ) const
inlineconstexpr

Definition at line 360 of file Enums.h.

References hasDenseSemantic(), and isWithPosLT().

Referenced by mlir::sparse_tensor::makeSparseTensorLevel().

◆ hasDenseSemantic()

bool mlir::sparse_tensor::LevelType::hasDenseSemantic ( ) const
inlineconstexpr

Check if the LevelType is considered to be dense-like.

Definition at line 343 of file Enums.h.

References isa().

Referenced by findAffine(), genIf(), getAllTidLvlsInLatPoints(), getNumBuffer(), getNumNonTrivialIdxExpOnSparseLvls(), and mlir::sparse_tensor::Merger::simplifyCond().

◆ hasSparseSemantic()

bool mlir::sparse_tensor::LevelType::hasSparseSemantic ( ) const
inlineconstexpr

◆ isa() [1/2]

◆ isa() [2/2]

template<LevelPropNonDefault p>
bool mlir::sparse_tensor::LevelType::isa ( ) const
inlineconstexpr

Check if the LevelType has the properties.

Definition at line 332 of file Enums.h.

◆ isValidLvlBits()

constexpr bool mlir::sparse_tensor::LevelType::isValidLvlBits ( uint64_t lvlBits)
inlinestaticconstexpr

◆ isWithCrdLT()

bool mlir::sparse_tensor::LevelType::isWithCrdLT ( ) const
inlineconstexpr

Check if the LevelType needs coordinates array.

Definition at line 354 of file Enums.h.

References hasSparseSemantic(), and isa().

Referenced by mlir::sparse_tensor::isWithCrdLT(), and mlir::sparse_tensor::makeSparseTensorLevel().

◆ isWithPosLT()

bool mlir::sparse_tensor::LevelType::isWithPosLT ( ) const
inlineconstexpr

Check if the LevelType needs positions array.

Definition at line 348 of file Enums.h.

References isa().

Referenced by getNumBuffer(), mlir::sparse_tensor::isWithPosLT(), and mlir::sparse_tensor::makeSparseTensorLevel().

◆ operator uint64_t()

mlir::sparse_tensor::LevelType::operator uint64_t ( ) const
inlineexplicit

Converts to uint64_t.

Definition at line 292 of file Enums.h.

◆ operator!=()

bool mlir::sparse_tensor::LevelType::operator!= ( const LevelType lhs) const
inline

Definition at line 297 of file Enums.h.

References LevelType(), and lhs.

◆ operator==()

bool mlir::sparse_tensor::LevelType::operator== ( const LevelType lhs) const
inline

Definition at line 294 of file Enums.h.

References LevelType(), and lhs.

◆ stripStorageIrrelevantProperties()

LevelType mlir::sparse_tensor::LevelType::stripStorageIrrelevantProperties ( ) const
inline

Definition at line 299 of file Enums.h.

References LevelType(), and mlir::sparse_tensor::SoA.

Referenced by getNormalizedEncodingForSpecifier().

◆ toMLIRString()

std::string mlir::sparse_tensor::LevelType::toMLIRString ( ) const
inline

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