MLIR  17.0.0git
Macros | Functions | Variables
SparseTensorDialect.cpp File Reference
#include <utility>
#include "mlir/Dialect/SparseTensor/IR/SparseTensor.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/OpImplementation.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"
+ Include dependency graph for SparseTensorDialect.cpp:

Go to the source code of this file.

Macros

#define GET_ATTRDEF_CLASSES
 
#define GET_TYPEDEF_CLASSES
 
#define RETURN_ON_FAIL(stmt)
 
#define ERROR_IF(COND, MSG)
 
#define RETURN_FAILURE_IF_FAILED(X)
 
#define GET_ATTRDEF_LIST
 
#define GET_TYPEDEF_LIST
 
#define GET_OP_LIST
 
#define GET_OP_CLASSES
 

Functions

template<typename T >
static int64_t getTypeRank (T t)
 
static bool acceptBitWidth (unsigned bitWidth)
 
static ParseResult parseOptionalStaticSlice (int64_t &result, AsmParser &parser)
 
static Type getIntegerOrIndexType (MLIRContext *ctx, unsigned bitwidth)
 
static std::optional< DimLevelTypeparseDLT (StringRef str)
 
static bool isCOOType (SparseTensorEncodingAttr enc, uint64_t s, bool isUnique)
 Returns true iff the given sparse tensor encoding attribute has a trailing COO region starting at the given dimension. More...
 
static SparseTensorEncodingAttr getNormalizedEncodingForSpecifier (SparseTensorEncodingAttr enc)
 We normalized sparse tensor encoding attribute by always using ordered/unique DLT 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 does not alter the sparse tensor memory layout. More...
 
static LogicalResult isInBounds (uint64_t dim, Value tensor)
 
static LogicalResult isMatchingWidth (Value result, unsigned width)
 
static LogicalResult verifySparsifierGetterSetter (StorageSpecifierKind mdKind, std::optional< APInt > dim, TypedValue< StorageSpecifierType > md, Operation *op)
 
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)
 

Variables

static const DimLevelType validDLTs []
 

Macro Definition Documentation

◆ ERROR_IF

#define ERROR_IF (   COND,
  MSG 
)
Value:
if (COND) { \
parser.emitError(parser.getNameLoc(), MSG); \
return {}; \
}

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 21 of file SparseTensorDialect.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 1040 of file SparseTensorDialect.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

◆ GET_TYPEDEF_CLASSES

#define GET_TYPEDEF_CLASSES

Definition at line 25 of file SparseTensorDialect.cpp.

◆ GET_TYPEDEF_LIST

#define GET_TYPEDEF_LIST

◆ RETURN_FAILURE_IF_FAILED

#define RETURN_FAILURE_IF_FAILED (   X)
Value:
if (failed(X)) { \
return failure(); \
}
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
Definition: LogicalResult.h:62
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
Definition: LogicalResult.h:72

Definition at line 360 of file SparseTensorDialect.cpp.

◆ RETURN_ON_FAIL

#define RETURN_ON_FAIL (   stmt)
Value:
if (failed(stmt)) { \
return {}; \
}

Function Documentation

◆ acceptBitWidth()

static bool acceptBitWidth ( unsigned  bitWidth)
static

Definition at line 44 of file SparseTensorDialect.cpp.

◆ getIntegerOrIndexType()

static Type getIntegerOrIndexType ( MLIRContext ctx,
unsigned  bitwidth 
)
static

Definition at line 113 of file SparseTensorDialect.cpp.

◆ getNormalizedEncodingForSpecifier()

static SparseTensorEncodingAttr getNormalizedEncodingForSpecifier ( SparseTensorEncodingAttr  enc)
static

We normalized sparse tensor encoding attribute by always using ordered/unique DLT 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 does not alter the sparse tensor memory layout.

Definition at line 489 of file SparseTensorDialect.cpp.

References mlir::sparse_tensor::getDimLevelType(), and mlir::sparse_tensor::getLevelFormat().

◆ getSpecifierSetDef()

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

Definition at line 654 of file SparseTensorDialect.cpp.

◆ getTypeRank()

template<typename T >
static int64_t getTypeRank ( t)
inlinestatic

Definition at line 36 of file SparseTensorDialect.cpp.

References mlir::sparse_tensor::getRankedTensorType().

Referenced by isInBounds().

◆ isCOOType()

static bool isCOOType ( SparseTensorEncodingAttr  enc,
uint64_t  s,
bool  isUnique 
)
static

Returns true iff the given sparse tensor encoding attribute has a trailing COO region starting at the given dimension.

Definition at line 410 of file SparseTensorDialect.cpp.

References mlir::sparse_tensor::getDimLevelType(), mlir::sparse_tensor::isCompressedDim(), mlir::sparse_tensor::isSingletonDim(), and mlir::sparse_tensor::isUniqueDLT().

Referenced by mlir::sparse_tensor::getCOOStart(), and mlir::sparse_tensor::isUniqueCOOType().

◆ isInBounds()

static LogicalResult isInBounds ( uint64_t  dim,
Value  tensor 
)
static

Definition at line 536 of file SparseTensorDialect.cpp.

References getTypeRank(), and mlir::success().

◆ isMatchingWidth()

static LogicalResult isMatchingWidth ( Value  result,
unsigned  width 
)
static

◆ parseDLT()

static std::optional<DimLevelType> parseDLT ( StringRef  str)
static

Definition at line 178 of file SparseTensorDialect.cpp.

References mlir::sparse_tensor::toMLIRString(), and validDLTs.

◆ parseOptionalStaticSlice()

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

◆ verifyNumBlockArgs()

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

◆ verifySparsifierGetterSetter()

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

Variable Documentation

◆ validDLTs

const DimLevelType validDLTs[]
static
Initial value:
= {
DimLevelType::Dense, DimLevelType::Compressed,
DimLevelType::CompressedNu, DimLevelType::CompressedNo,
DimLevelType::CompressedNuNo, DimLevelType::Singleton,
DimLevelType::SingletonNu, DimLevelType::SingletonNo,
DimLevelType::SingletonNuNo}

Definition at line 171 of file SparseTensorDialect.cpp.

Referenced by parseDLT().