MLIR  19.0.0git
Classes | Namespaces | Macros | Functions | Variables
SparseTensorDialect.cpp File Reference
#include <utility>
#include "Detail/DimLvlMapParser.h"
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorType.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "llvm/ADT/Bitset.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/FormatVariadic.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.cpp.inc"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorAttrEnums.cpp.inc"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorTypes.cpp.inc"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOps.cpp.inc"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorOpsDialect.cpp.inc"

Go to the source code of this file.

Classes

struct  RemoveUnusedLvlCrds
 

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::sparse_tensor
 

Macros

#define GET_ATTRDEF_CLASSES
 
#define GET_TYPEDEF_CLASSES
 
#define GET_ATTRDEF_LIST
 
#define GET_TYPEDEF_LIST
 
#define GET_OP_LIST
 
#define GET_OP_CLASSES
 

Functions

static mlir::ParseResult parseLevelRange (AsmParser &parser, Level &lvlLo, Level &lvlHi)
 Parses a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1. More...
 
static void printLevelRange (AsmPrinter &p, Level lo, Level hi)
 Prints a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1. More...
 
llvm::hash_code mlir::sparse_tensor::hash_value (LevelType lt)
 
static constexpr bool acceptBitWidth (unsigned bitWidth)
 
static SmallVector< SizegetSparseFieldShape (const SparseTensorEncodingAttr enc, std::optional< ArrayRef< int64_t >> dimShape)
 
static ParseResult parseOptionalStaticSlice (int64_t &result, AsmParser &parser)
 
static SparseTensorEncodingAttr getNormalizedEncodingForSpecifier (SparseTensorEncodingAttr enc)
 We normalized sparse tensor encoding attribute by always using ordered/unique LT such that "compressed_nu_no" and "compressed_nu" (as well as other variants) lead to the same storage specifier type, and stripping irrelevant fields that do not alter the sparse tensor memory layout. More...
 
static LogicalResult lvlIsInBounds (Level lvl, Value tensor)
 
static LogicalResult isMatchingWidth (Value mem, unsigned width)
 
static LogicalResult verifySparsifierGetterSetter (StorageSpecifierKind mdKind, std::optional< Level > lvl, TypedValue< StorageSpecifierType > md, Operation *op)
 
static Type getFieldElemType (SparseTensorType stt, SparseTensorFieldKind kind)
 
static LogicalResult verifyPackUnPack (Operation *op, bool requiresStaticShape, SparseTensorType stt, RankedTensorType valTp, TypeRange lvlTps)
 
template<typename ToBufferOp >
static LogicalResult inferSparseBufferType (ValueRange ops, DictionaryAttr attr, OpaqueProperties prop, RegionRange region, SmallVectorImpl< mlir::Type > &ret)
 
template<typename SpecifierOp >
static SetStorageSpecifierOp getSpecifierSetDef (SpecifierOp op)
 
template<class T >
static LogicalResult verifyNumBlockArgs (T *op, Region &region, const char *regionName, TypeRange inputTypes, Type outputType)
 
static ParseResult parseLevelRange (OpAsmParser &parser, IntegerAttr &lvlLoAttr, IntegerAttr &lvlHiAttr)
 Parses a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1. More...
 
static void printLevelRange (OpAsmPrinter &p, Operation *, IntegerAttr lvlLo, IntegerAttr lvlHi)
 Prints a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1. More...
 
static ParseResult parseSparseSpaceLoop (OpAsmParser &parser, OperationState &state, SmallVectorImpl< OpAsmParser::Argument > &iterators, SmallVectorImpl< OpAsmParser::Argument > &iterArgs)
 
static void printInitializationList (OpAsmPrinter &p, Block::BlockArgListType blocksArgs, ValueRange initializers, StringRef prefix="")
 Prints the initialization list in the form of <prefix>(inner = outer, inner2 = outer2, <...>) where 'inner' values are assumed to be region arguments and 'outer' values are regular SSA values. More...
 
static void printUsedCrdsList (OpAsmPrinter &p, unsigned spaceDim, Block::BlockArgListType blocksArgs, LevelSet crdUsedLvls)
 

Variables

static constexpr Level kInvalidLevel = -1u
 
static constexpr Level kInvalidFieldIndex = -1u
 
static constexpr FieldIndex kDataFieldStartingIdx = 0
 

Macro Definition Documentation

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 31 of file SparseTensorDialect.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 2540 of file SparseTensorDialect.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

◆ GET_TYPEDEF_CLASSES

#define GET_TYPEDEF_CLASSES

Definition at line 43 of file SparseTensorDialect.cpp.

◆ GET_TYPEDEF_LIST

#define GET_TYPEDEF_LIST

Function Documentation

◆ acceptBitWidth()

static constexpr bool acceptBitWidth ( unsigned  bitWidth)
staticconstexpr

Definition at line 61 of file SparseTensorDialect.cpp.

◆ getFieldElemType()

static Type getFieldElemType ( SparseTensorType  stt,
SparseTensorFieldKind  kind 
)
static

Definition at line 1274 of file SparseTensorDialect.cpp.

◆ getNormalizedEncodingForSpecifier()

static SparseTensorEncodingAttr getNormalizedEncodingForSpecifier ( SparseTensorEncodingAttr  enc)
static

We normalized sparse tensor encoding attribute by always using ordered/unique LT such that "compressed_nu_no" and "compressed_nu" (as well as other variants) lead to the same storage specifier type, and stripping irrelevant fields that do not alter the sparse tensor memory layout.

Definition at line 1206 of file SparseTensorDialect.cpp.

References mlir::get(), and mlir::sparse_tensor::LevelType::stripStorageIrrelevantProperties().

◆ getSparseFieldShape()

static SmallVector<Size> getSparseFieldShape ( const SparseTensorEncodingAttr  enc,
std::optional< ArrayRef< int64_t >>  dimShape 
)
static

◆ getSpecifierSetDef()

template<typename SpecifierOp >
static SetStorageSpecifierOp getSpecifierSetDef ( SpecifierOp  op)
static

Definition at line 1711 of file SparseTensorDialect.cpp.

◆ inferSparseBufferType()

template<typename ToBufferOp >
static LogicalResult inferSparseBufferType ( ValueRange  ops,
DictionaryAttr  attr,
OpaqueProperties  prop,
RegionRange  region,
SmallVectorImpl< mlir::Type > &  ret 
)
static

◆ isMatchingWidth()

static LogicalResult isMatchingWidth ( Value  mem,
unsigned  width 
)
static

◆ lvlIsInBounds()

static LogicalResult lvlIsInBounds ( Level  lvl,
Value  tensor 
)
static

◆ parseLevelRange() [1/2]

static ParseResult parseLevelRange ( mlir::AsmParser parser,
mlir::sparse_tensor::Level lvlLo,
mlir::sparse_tensor::Level lvlHi 
)
static

Parses a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1.

Definition at line 2083 of file SparseTensorDialect.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getNameLoc(), mlir::AsmParser::parseInteger(), and mlir::AsmParser::parseOptionalKeyword().

Referenced by parseLevelRange().

◆ parseLevelRange() [2/2]

static ParseResult parseLevelRange ( OpAsmParser parser,
IntegerAttr &  lvlLoAttr,
IntegerAttr &  lvlHiAttr 
)
static

Parses a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1.

Definition at line 2104 of file SparseTensorDialect.cpp.

References mlir::get(), mlir::AsmParser::getBuilder(), mlir::Builder::getIndexType(), and parseLevelRange().

◆ parseOptionalStaticSlice()

static ParseResult parseOptionalStaticSlice ( int64_t &  result,
AsmParser parser 
)
static

◆ parseSparseSpaceLoop()

static ParseResult parseSparseSpaceLoop ( OpAsmParser parser,
OperationState state,
SmallVectorImpl< OpAsmParser::Argument > &  iterators,
SmallVectorImpl< OpAsmParser::Argument > &  iterArgs 
)
static

Definition at line 2135 of file SparseTensorDialect.cpp.

◆ printInitializationList()

static void printInitializationList ( OpAsmPrinter p,
Block::BlockArgListType  blocksArgs,
ValueRange  initializers,
StringRef  prefix = "" 
)
static

Prints the initialization list in the form of <prefix>(inner = outer, inner2 = outer2, <...>) where 'inner' values are assumed to be region arguments and 'outer' values are regular SSA values.

Definition at line 2367 of file SparseTensorDialect.cpp.

◆ printLevelRange() [1/2]

static void printLevelRange ( mlir::AsmPrinter p,
mlir::sparse_tensor::Level  lo,
mlir::sparse_tensor::Level  hi 
)
static

Prints a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1.

Definition at line 2117 of file SparseTensorDialect.cpp.

Referenced by printLevelRange().

◆ printLevelRange() [2/2]

static void printLevelRange ( OpAsmPrinter p,
Operation ,
IntegerAttr  lvlLo,
IntegerAttr  lvlHi 
)
static

Prints a level range in the form "$lo `to` $hi" or simply "$lo" if $hi - $lo = 1.

Definition at line 2127 of file SparseTensorDialect.cpp.

References printLevelRange().

◆ printUsedCrdsList()

static void printUsedCrdsList ( OpAsmPrinter p,
unsigned  spaceDim,
Block::BlockArgListType  blocksArgs,
LevelSet  crdUsedLvls 
)
static

Definition at line 2383 of file SparseTensorDialect.cpp.

References mlir::sparse_tensor::LevelSet::empty().

◆ verifyNumBlockArgs()

template<class T >
static LogicalResult verifyNumBlockArgs ( T *  op,
Region region,
const char *  regionName,
TypeRange  inputTypes,
Type  outputType 
)
static

Definition at line 1730 of file SparseTensorDialect.cpp.

◆ verifyPackUnPack()

static LogicalResult verifyPackUnPack ( Operation op,
bool  requiresStaticShape,
SparseTensorType  stt,
RankedTensorType  valTp,
TypeRange  lvlTps 
)
static

Definition at line 1288 of file SparseTensorDialect.cpp.

◆ verifySparsifierGetterSetter()

static LogicalResult verifySparsifierGetterSetter ( StorageSpecifierKind  mdKind,
std::optional< Level lvl,
TypedValue< StorageSpecifierType >  md,
Operation op 
)
static

Definition at line 1243 of file SparseTensorDialect.cpp.

Variable Documentation

◆ kDataFieldStartingIdx

constexpr FieldIndex kDataFieldStartingIdx = 0
staticconstexpr

◆ kInvalidFieldIndex

constexpr Level kInvalidFieldIndex = -1u
staticconstexpr

Definition at line 99 of file SparseTensorDialect.cpp.

◆ kInvalidLevel

constexpr Level kInvalidLevel = -1u
staticconstexpr