14 #ifndef MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
15 #define MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
58 #define DECL_SPARSEVALUES(VNAME, V) \
59 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseValues##VNAME( \
60 StridedMemRefType<V, 1> *out, void *tensor);
62 #undef DECL_SPARSEVALUES
66 #define DECL_SPARSEPOSITIONS(PNAME, P) \
67 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparsePositions##PNAME( \
68 StridedMemRefType<P, 1> *out, void *tensor, index_type lvl);
70 #undef DECL_SPARSEPOSITIONS
74 #define DECL_SPARSECOORDINATES(CNAME, C) \
75 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinates##CNAME( \
76 StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);
78 #undef DECL_SPARSECOORDINATES
82 #define DECL_SPARSECOORDINATES(CNAME, C) \
83 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinatesBuffer##CNAME( \
84 StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);
86 #undef DECL_SPARSECOORDINATES
90 #define DECL_LEXINSERT(VNAME, V) \
91 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_lexInsert##VNAME( \
92 void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \
93 StridedMemRefType<V, 0> *vref);
98 #define DECL_EXPINSERT(VNAME, V) \
99 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_expInsert##VNAME( \
100 void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \
101 StridedMemRefType<V, 1> *vref, StridedMemRefType<bool, 1> *fref, \
102 StridedMemRefType<index_type, 1> *aref, index_type count);
104 #undef DECL_EXPINSERT
121 #define DECL_READTOBUFFERS(VNAME, V, CNAME, C) \
122 MLIR_CRUNNERUTILS_EXPORT bool \
123 _mlir_ciface_getSparseTensorReaderReadToBuffers##CNAME##VNAME( \
124 void *p, StridedMemRefType<index_type, 1> *dim2lvlRef, \
125 StridedMemRefType<index_type, 1> *lvl2dimRef, \
126 StridedMemRefType<C, 1> *cref, StridedMemRefType<V, 1> *vref) \
127 MLIR_SPARSETENSOR_FOREVERY_V_O(DECL_READTOBUFFERS)
128 #undef DECL_READTOBUFFERS
136 #define DECL_OUTNEXT(VNAME, V) \
137 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterNext##VNAME( \
138 void *p, index_type dimRank, \
139 StridedMemRefType<index_type, 1> *dimCoordsRef, \
140 StridedMemRefType<V, 0> *vref);
#define MLIR_CRUNNERUTILS_EXPORT
#define MLIR_SPARSETENSOR_FOREVERY_O(DO)
#define MLIR_SPARSETENSOR_FOREVERY_V(DO)
MLIR_CRUNNERUTILS_EXPORT index_type sparseDimSize(void *tensor, index_type d)
Tensor-storage method to get the size of the given dimension.
MLIR_CRUNNERUTILS_EXPORT index_type sparseLvlSize(void *tensor, index_type l)
Tensor-storage method to get the size of the given level.
MLIR_CRUNNERUTILS_EXPORT void delSparseTensor(void *tensor)
Releases the memory for the tensor-storage object.
#define DECL_LEXINSERT(VNAME, V)
Tensor-storage method to insert elements in lexicographical level-coordinate order.
MLIR_CRUNNERUTILS_EXPORT index_type getSparseTensorReaderNSE(void *p)
Returns the number of stored elements for the sparse tensor being read.
#define DECL_OUTNEXT(VNAME, V)
Outputs an element for the sparse tensor.
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 ...
#define DECL_EXPINSERT(VNAME, V)
Tensor-storage method to insert using expansion.
#define DECL_SPARSEVALUES(VNAME, V)
Tensor-storage method to obtain direct access to the values array.
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.
MLIR_CRUNNERUTILS_EXPORT void delSparseTensorReader(void *p)
Releases the SparseTensorReader and closes the associated file.
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_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.
#define DECL_SPARSECOORDINATES(CNAME, C)
Tensor-storage method to obtain direct access to the coordinates array for the given level.
MLIR_CRUNNERUTILS_EXPORT char * getTensorFilename(index_type id)
Helper function to read a sparse tensor filename from the environment, defined with the naming conven...
#define DECL_SPARSEPOSITIONS(PNAME, P)
Tensor-storage method to obtain direct access to the positions array for the given level.
MLIR_CRUNNERUTILS_EXPORT void endLexInsert(void *tensor)
Tensor-storage method to finalize lexicographic insertions.
MLIR_CRUNNERUTILS_EXPORT void delSparseTensorWriter(void *p)
Finalizes the outputing of a sparse tensor to a file and releases the SparseTensorWriter.
MLIR_CRUNNERUTILS_EXPORT void * createSparseTensorWriter(char *filename)
Creates a SparseTensorWriter for outputting a sparse tensor to a file with the given file name.
OverheadType
Encoding of overhead types (both position overhead and coordinate overhead), for "overloading" @newSp...
Action
The actions performed by @newSparseTensor.
PrimaryType
Encoding of the elemental type, for "overloading" @newSparseTensor.
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...
StridedMemRef descriptor type with static rank.