14 #ifndef MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
15 #define MLIR_EXECUTIONENGINE_SPARSETENSORRUNTIME_H
57 #define DECL_SPARSEVALUES(VNAME, V) \
58 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseValues##VNAME( \
59 StridedMemRefType<V, 1> *out, void *tensor);
61 #undef DECL_SPARSEVALUES
65 #define DECL_SPARSEPOSITIONS(PNAME, P) \
66 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparsePositions##PNAME( \
67 StridedMemRefType<P, 1> *out, void *tensor, index_type lvl);
69 #undef DECL_SPARSEPOSITIONS
73 #define DECL_SPARSECOORDINATES(CNAME, C) \
74 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinates##CNAME( \
75 StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);
77 #undef DECL_SPARSECOORDINATES
81 #define DECL_SPARSECOORDINATES(CNAME, C) \
82 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_sparseCoordinatesBuffer##CNAME( \
83 StridedMemRefType<C, 1> *out, void *tensor, index_type lvl);
85 #undef DECL_SPARSECOORDINATES
89 #define DECL_LEXINSERT(VNAME, V) \
90 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_lexInsert##VNAME( \
91 void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \
92 StridedMemRefType<V, 0> *vref);
97 #define DECL_EXPINSERT(VNAME, V) \
98 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_expInsert##VNAME( \
99 void *tensor, StridedMemRefType<index_type, 1> *lvlCoordsRef, \
100 StridedMemRefType<V, 1> *vref, StridedMemRefType<bool, 1> *fref, \
101 StridedMemRefType<index_type, 1> *aref, index_type count);
103 #undef DECL_EXPINSERT
120 #define DECL_READTOBUFFERS(VNAME, V, CNAME, C) \
121 MLIR_CRUNNERUTILS_EXPORT bool \
122 _mlir_ciface_getSparseTensorReaderReadToBuffers##CNAME##VNAME( \
123 void *p, StridedMemRefType<index_type, 1> *dim2lvlRef, \
124 StridedMemRefType<index_type, 1> *lvl2dimRef, \
125 StridedMemRefType<C, 1> *cref, StridedMemRefType<V, 1> *vref) \
126 MLIR_SPARSETENSOR_FOREVERY_V_O(DECL_READTOBUFFERS)
127 #undef DECL_READTOBUFFERS
135 #define DECL_OUTNEXT(VNAME, V) \
136 MLIR_CRUNNERUTILS_EXPORT void _mlir_ciface_outSparseTensorWriterNext##VNAME( \
137 void *p, index_type dimRank, \
138 StridedMemRefType<index_type, 1> *dimCoordsRef, \
139 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.