MLIR  16.0.0git
SparseTensor.h
Go to the documentation of this file.
1 //===-- mlir-c/Dialect/SparseTensor.h - C API for SparseTensor ----*- C -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM
4 // Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef MLIR_C_DIALECT_SPARSETENSOR_H
11 #define MLIR_C_DIALECT_SPARSETENSOR_H
12 
13 #include "mlir-c/AffineMap.h"
14 #include "mlir-c/IR.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor);
21 
22 /// Dimension level types (and properties) that define sparse tensors.
23 /// See the documentation in SparseTensorAttrDefs.td for their meaning.
24 ///
25 /// These correspond to SparseTensorEncodingAttr::DimLevelType in the C++ API.
26 /// If updating, keep them in sync and update the static_assert in the impl
27 /// file.
38 };
39 
40 //===----------------------------------------------------------------------===//
41 // SparseTensorEncodingAttr
42 //===----------------------------------------------------------------------===//
43 
44 /// Checks whether the given attribute is a sparse_tensor.encoding attribute.
47 
48 /// Creates a sparse_tensor.encoding attribute with the given parameters.
50  MlirContext ctx, intptr_t numDimLevelTypes,
51  enum MlirSparseTensorDimLevelType const *dimLevelTypes,
52  MlirAffineMap dimOrdering, int pointerBitWidth, int indexBitWidth);
53 
54 /// Returns the number of dim level types in a sparse_tensor.encoding attribute.
55 MLIR_CAPI_EXPORTED intptr_t
57 
58 /// Returns a specified dim level type in a sparse_tensor.encoding attribute.
60 mlirSparseTensorEncodingAttrGetDimLevelType(MlirAttribute attr, intptr_t pos);
61 
62 /// Returns the dimension ordering in a sparse_tensor.encoding attribute.
63 MLIR_CAPI_EXPORTED MlirAffineMap
65 
66 /// Returns the pointer bit width in a sparse_tensor.encoding attribute.
69 
70 /// Returns the index bit width in a sparse_tensor.encoding attribute.
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #include "mlir/Dialect/SparseTensor/Transforms/Passes.capi.h.inc"
79 
80 #endif // MLIR_C_DIALECT_SPARSETENSOR_H
MLIR_CAPI_EXPORTED MlirAffineMap mlirSparseTensorEncodingAttrGetDimOrdering(MlirAttribute attr)
Returns the dimension ordering in a sparse_tensor.encoding attribute.
MLIR_CAPI_EXPORTED enum MlirSparseTensorDimLevelType mlirSparseTensorEncodingAttrGetDimLevelType(MlirAttribute attr, intptr_t pos)
Returns a specified dim level type in a sparse_tensor.encoding attribute.
#define MLIR_CAPI_EXPORTED
Definition: Support.h:46
MLIR_CAPI_EXPORTED int mlirSparseTensorEncodingAttrGetPointerBitWidth(MlirAttribute attr)
Returns the pointer bit width in a sparse_tensor.encoding attribute.
MLIR_CAPI_EXPORTED int mlirSparseTensorEncodingAttrGetIndexBitWidth(MlirAttribute attr)
Returns the index bit width in a sparse_tensor.encoding attribute.
MLIR_CAPI_EXPORTED intptr_t mlirSparseTensorEncodingGetNumDimLevelTypes(MlirAttribute attr)
Returns the number of dim level types in a sparse_tensor.encoding attribute.
MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor)
MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr)
Checks whether the given attribute is a sparse_tensor.encoding attribute.
MLIR_CAPI_EXPORTED MlirAttribute mlirSparseTensorEncodingAttrGet(MlirContext ctx, intptr_t numDimLevelTypes, enum MlirSparseTensorDimLevelType const *dimLevelTypes, MlirAffineMap dimOrdering, int pointerBitWidth, int indexBitWidth)
Creates a sparse_tensor.encoding attribute with the given parameters.
MlirSparseTensorDimLevelType
Dimension level types (and properties) that define sparse tensors.
Definition: SparseTensor.h:28