MLIR  20.0.0git
Macros | Functions
SparseTensorRuntime.h File Reference
#include "mlir/Dialect/SparseTensor/IR/Enums.h"
#include "mlir/ExecutionEngine/CRunnerUtils.h"
#include "mlir/ExecutionEngine/Float16bits.h"
#include <cinttypes>
#include <complex>
#include <vector>

Go to the source code of this file.

Macros

#define DECL_SPARSEVALUES(VNAME, V)
 Tensor-storage method to obtain direct access to the values array. More...
 
#define DECL_SPARSEPOSITIONS(PNAME, P)
 Tensor-storage method to obtain direct access to the positions array for the given level. More...
 
#define DECL_SPARSECOORDINATES(CNAME, C)
 Tensor-storage method to obtain direct access to the coordinates array for the given level. More...
 
#define DECL_SPARSECOORDINATES(CNAME, C)
 Tensor-storage method to obtain direct access to the coordinates array for the given level. More...
 
#define DECL_LEXINSERT(VNAME, V)
 Tensor-storage method to insert elements in lexicographical level-coordinate order. More...
 
#define DECL_EXPINSERT(VNAME, V)
 Tensor-storage method to insert using expansion. More...
 
#define DECL_READTOBUFFERS(VNAME, V, CNAME, C)
 Reads the sparse tensor, stores the coordinates and values to the given memrefs of a COO in AoS format. More...
 
#define DECL_OUTNEXT(VNAME, V)
 Outputs an element for the sparse tensor. More...
 

Functions

MLIR_CRUNNERUTILS_EXPORT void * _mlir_ciface_newSparseTensor (StridedMemRefType< index_type, 1 > *dimSizesRef, StridedMemRefType< index_type, 1 > *lvlSizesRef, StridedMemRefType< LevelType, 1 > *lvlTypesRef, StridedMemRefType< index_type, 1 > *dim2lvlRef, StridedMemRefType< index_type, 1 > *lvl2dimRef, OverheadType posTp, OverheadType crdTp, PrimaryType valTp, Action action, void *ptr)
 This is the "swiss army knife" method for materializing sparse tensors into the computation. More...
 
MLIR_CRUNNERUTILS_EXPORT void * _mlir_ciface_createCheckedSparseTensorReader (char *filename, StridedMemRefType< index_type, 1 > *dimShapeRef, PrimaryType valTp)
 Constructs a new SparseTensorReader object, opens the file, reads the header, and validates that the actual contents of the file match the expected dimShapeRef and valTp. More...
 
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_getSparseTensorReaderDimSizes (StridedMemRefType< index_type, 1 > *out, void *p)
 SparseTensorReader method to obtain direct access to the dimension-sizes array. More...
 
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterMetaData (void *p, index_type dimRank, index_type nse, StridedMemRefType< index_type, 1 > *dimSizesRef)
 Outputs the sparse tensor dim-rank, nse, and dim-shape. More...
 
MLIR_CRUNNERUTILS_EXPORT index_type sparseLvlSize (void *tensor, index_type l)
 Tensor-storage method to get the size of the given level. More...
 
MLIR_CRUNNERUTILS_EXPORT index_type sparseDimSize (void *tensor, index_type d)
 Tensor-storage method to get the size of the given dimension. More...
 
MLIR_CRUNNERUTILS_EXPORT void endLexInsert (void *tensor)
 Tensor-storage method to finalize lexicographic insertions. More...
 
MLIR_CRUNNERUTILS_EXPORT void delSparseTensor (void *tensor)
 Releases the memory for the tensor-storage object. More...
 
MLIR_CRUNNERUTILS_EXPORT char * getTensorFilename (index_type id)
 Helper function to read a sparse tensor filename from the environment, defined with the naming convention ${TENSOR0}, ${TENSOR1}, etc. More...
 
MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderNSE (void *p)
 Returns the number of stored elements for the sparse tensor being read. More...
 
MLIR_CRUNNERUTILS_EXPORT void delSparseTensorReader (void *p)
 Releases the SparseTensorReader and closes the associated file. More...
 
MLIR_CRUNNERUTILS_EXPORT void * createSparseTensorWriter (char *filename)
 Creates a SparseTensorWriter for outputting a sparse tensor to a file with the given file name. More...
 
MLIR_CRUNNERUTILS_EXPORT void delSparseTensorWriter (void *p)
 Finalizes the outputing of a sparse tensor to a file and releases the SparseTensorWriter. More...
 

Macro Definition Documentation

◆ DECL_EXPINSERT

#define DECL_EXPINSERT (   VNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_expInsert##VNAME( \
void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \
#define MLIR_CRUNNERUTILS_EXPORT
Definition: CRunnerUtils.h:31
uint64_t index_type
This type is used in the public API at all places where MLIR expects values with the built-in type "i...
Definition: Enums.h:47
StridedMemRef descriptor type with static rank.
Definition: CRunnerUtils.h:131

Tensor-storage method to insert using expansion.

Definition at line 98 of file SparseTensorRuntime.h.

◆ DECL_LEXINSERT

#define DECL_LEXINSERT (   VNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_lexInsert##VNAME( \
void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \

Tensor-storage method to insert elements in lexicographical level-coordinate order.

Definition at line 90 of file SparseTensorRuntime.h.

◆ DECL_OUTNEXT

#define DECL_OUTNEXT (   VNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterNext##VNAME( \
void *p, index_type dimRank, \

Outputs an element for the sparse tensor.

Definition at line 136 of file SparseTensorRuntime.h.

◆ DECL_READTOBUFFERS

#define DECL_READTOBUFFERS (   VNAME,
  V,
  CNAME,
 
)
Value:
_mlir_ciface_getSparseTensorReaderReadToBuffers##CNAME##VNAME( \
void *p, StridedMemRefType<index_type, 1> *dim2lvlRef, \
MLIR_SPARSETENSOR_FOREVERY_V_O(DECL_READTOBUFFERS)
#define DECL_READTOBUFFERS(VNAME, V, CNAME, C)
Reads the sparse tensor, stores the coordinates and values to the given memrefs of a COO in AoS forma...

Reads the sparse tensor, stores the coordinates and values to the given memrefs of a COO in AoS format.

Returns a boolean to indicate whether the COO elements are sorted.

Definition at line 121 of file SparseTensorRuntime.h.

◆ DECL_SPARSECOORDINATES [1/2]

#define DECL_SPARSECOORDINATES (   CNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinates##CNAME( \
StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);

Tensor-storage method to obtain direct access to the coordinates array for the given level.

Tensor-storage method to obtain direct access to the coordinates array buffer for the given level (provides an AoS view into the library).

Definition at line 82 of file SparseTensorRuntime.h.

◆ DECL_SPARSECOORDINATES [2/2]

#define DECL_SPARSECOORDINATES (   CNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinatesBuffer##CNAME( \
StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);

Tensor-storage method to obtain direct access to the coordinates array for the given level.

Tensor-storage method to obtain direct access to the coordinates array buffer for the given level (provides an AoS view into the library).

Definition at line 82 of file SparseTensorRuntime.h.

◆ DECL_SPARSEPOSITIONS

#define DECL_SPARSEPOSITIONS (   PNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparsePositions##PNAME( \
StridedMemRefType<P, 1> *out, void *tensor, index_type lvl);

Tensor-storage method to obtain direct access to the positions array for the given level.

Definition at line 66 of file SparseTensorRuntime.h.

◆ DECL_SPARSEVALUES

#define DECL_SPARSEVALUES (   VNAME,
 
)
Value:
MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseValues##VNAME( \
StridedMemRefType<V, 1> *out, void *tensor);

Tensor-storage method to obtain direct access to the values array.

Definition at line 58 of file SparseTensorRuntime.h.

Function Documentation

◆ _mlir_ciface_createCheckedSparseTensorReader()

MLIR_CRUNNERUTILS_EXPORT void* _mlir_ciface_createCheckedSparseTensorReader ( char *  filename,
StridedMemRefType< index_type, 1 > *  dimShapeRef,
PrimaryType  valTp 
)

Constructs a new SparseTensorReader object, opens the file, reads the header, and validates that the actual contents of the file match the expected dimShapeRef and valTp.

◆ _mlir_ciface_getSparseTensorReaderDimSizes()

MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_getSparseTensorReaderDimSizes ( StridedMemRefType< index_type, 1 > *  out,
void *  p 
)

SparseTensorReader method to obtain direct access to the dimension-sizes array.

◆ _mlir_ciface_newSparseTensor()

MLIR_CRUNNERUTILS_EXPORT void* _mlir_ciface_newSparseTensor ( StridedMemRefType< index_type, 1 > *  dimSizesRef,
StridedMemRefType< index_type, 1 > *  lvlSizesRef,
StridedMemRefType< LevelType, 1 > *  lvlTypesRef,
StridedMemRefType< index_type, 1 > *  dim2lvlRef,
StridedMemRefType< index_type, 1 > *  lvl2dimRef,
OverheadType  posTp,
OverheadType  crdTp,
PrimaryType  valTp,
Action  action,
void *  ptr 
)

This is the "swiss army knife" method for materializing sparse tensors into the computation.

The types of the ptr argument and the result depend on the action, as explained in the following table, where "STS" means a sparse-tensor-storage object.

Action: <tt>ptr</tt>: Returns:

kEmpty - STS, empty kFromReader reader STS, input from reader kPack buffers STS, from level buffers kSortCOOInPlace STS STS, sorted in place

◆ _mlir_ciface_outSparseTensorWriterMetaData()

MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterMetaData ( void *  p,
index_type  dimRank,
index_type  nse,
StridedMemRefType< index_type, 1 > *  dimSizesRef 
)

Outputs the sparse tensor dim-rank, nse, and dim-shape.

◆ createSparseTensorWriter()

MLIR_CRUNNERUTILS_EXPORT void* createSparseTensorWriter ( char *  filename)

Creates a SparseTensorWriter for outputting a sparse tensor to a file with the given file name.

When the file name is empty, std::cout is used. Only the extended FROSTT format is supported currently.

◆ delSparseTensor()

MLIR_CRUNNERUTILS_EXPORT void delSparseTensor ( void *  tensor)

Releases the memory for the tensor-storage object.

◆ delSparseTensorReader()

MLIR_CRUNNERUTILS_EXPORT void delSparseTensorReader ( void *  p)

Releases the SparseTensorReader and closes the associated file.

◆ delSparseTensorWriter()

MLIR_CRUNNERUTILS_EXPORT void delSparseTensorWriter ( void *  p)

Finalizes the outputing of a sparse tensor to a file and releases the SparseTensorWriter.

◆ endLexInsert()

MLIR_CRUNNERUTILS_EXPORT void endLexInsert ( void *  tensor)

Tensor-storage method to finalize lexicographic insertions.

◆ getSparseTensorReaderNSE()

MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderNSE ( void *  p)

Returns the number of stored elements for the sparse tensor being read.

◆ getTensorFilename()

MLIR_CRUNNERUTILS_EXPORT char* getTensorFilename ( index_type  id)

Helper function to read a sparse tensor filename from the environment, defined with the naming convention ${TENSOR0}, ${TENSOR1}, etc.

◆ sparseDimSize()

MLIR_CRUNNERUTILS_EXPORT index_type sparseDimSize ( void *  tensor,
index_type  d 
)

Tensor-storage method to get the size of the given dimension.

◆ sparseLvlSize()

MLIR_CRUNNERUTILS_EXPORT index_type sparseLvlSize ( void *  tensor,
index_type  l 
)

Tensor-storage method to get the size of the given level.