MLIR  19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
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. More...
 
 LevelType (LevelFormat f)
 Constructs a LevelType with the given format using all default properties. More...
 
 operator uint64_t () const
 Converts to uint64_t. More...
 
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. More...
 
constexpr uint64_t getM () const
 Get M of NOutOfM level type. More...
 
constexpr LevelFormat getLvlFmt () const
 Get the LevelFormat of the LevelType. More...
 
template<LevelFormat... fmt>
constexpr bool isa () const
 Check if the LevelType is in the LevelFormat. More...
 
template<LevelPropNonDefault p>
constexpr bool isa () const
 Check if the LevelType has the properties. More...
 
constexpr bool hasSparseSemantic () const
 Check if the LevelType is considered to be sparse. More...
 
constexpr bool hasDenseSemantic () const
 Check if the LevelType is considered to be dense-like. More...
 
constexpr bool isWithPosLT () const
 Check if the LevelType needs positions array. More...
 
constexpr bool isWithCrdLT () const
 Check if the LevelType needs coordinates array. More...
 
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. More...
 
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. More...
 
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]

constexpr 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(), 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 isValidLvlBits().

Member Function Documentation

◆ buildLvlType() [1/2]

static 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]

static 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(), and buildLvlType().

◆ getLvlFmt()

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

Get the LevelFormat of the LevelType.

Definition at line 320 of file Enums.h.

Referenced by mlir::sparse_tensor::getLevelFormat(), isa(), mlir::sparse_tensor::makeSparseTensorLevel(), and toMLIRString().

◆ getM()

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

Get M of NOutOfM level type.

Definition at line 314 of file Enums.h.

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

◆ getN()

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

Get N of NOutOfM level type.

Definition at line 308 of file Enums.h.

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

◆ hasDenseSemantic()

constexpr 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.

Referenced by findAffine(), genIf(), getAllTidLvlsInLatPoints(), and getNumNonTrivialIdxExpOnSparseLvls().

◆ hasSparseSemantic()

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

Check if the LevelType is considered to be sparse.

Definition at line 337 of file Enums.h.

References mlir::sparse_tensor::Compressed, isa(), mlir::sparse_tensor::LooseCompressed, mlir::sparse_tensor::NOutOfM, and mlir::sparse_tensor::Singleton.

Referenced by genIf(), and isWithCrdLT().

◆ isa() [1/2]

template<LevelFormat... fmt>
constexpr bool mlir::sparse_tensor::LevelType::isa ( ) const
inlineconstexpr

◆ isa() [2/2]

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

Check if the LevelType has the properties.

Definition at line 332 of file Enums.h.

◆ isValidLvlBits()

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

◆ isWithCrdLT()

constexpr 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().

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

◆ isWithPosLT()

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

Check if the LevelType needs positions array.

Definition at line 348 of file Enums.h.

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

◆ 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.

◆ operator==()

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

Definition at line 294 of file Enums.h.

◆ 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: