forked from OSchip/llvm-project
[mlir][sparse] improve sparse attribute documentation
Moved some parts from comments (not user facing) to the actual description (user facing). Rephrased a bit as well. Reviewed By: Peiming Differential Revision: https://reviews.llvm.org/D131418
This commit is contained in:
parent
0c52ab3968
commit
6b3bc7cd3c
|
@ -31,6 +31,28 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
|
||||||
passes that run before this sparse compiler pass need to be
|
passes that run before this sparse compiler pass need to be
|
||||||
aware of the semantics of tensor types with such an encoding.
|
aware of the semantics of tensor types with such an encoding.
|
||||||
|
|
||||||
|
The attribute consists of the following fields.
|
||||||
|
- Dimension level type for each dimension of a tensor type:
|
||||||
|
- **dense** : dimension is dense, all entries along this dimension
|
||||||
|
are stored.
|
||||||
|
- **compressed** : dimension is sparse, only nonzeros along this dimensions
|
||||||
|
are stored, without duplicates, i.e., compressed (unique).
|
||||||
|
- Dimension ordering on the indices of this tensor type. Unlike dense
|
||||||
|
storage, most sparse storage schemes do not provide fast random access.
|
||||||
|
This affine map specifies the order of dimensions that should be supported
|
||||||
|
by the sparse storage scheme. For example, for a 2-d tensor, "(i,j) -> (i,j)"
|
||||||
|
requests row-wise storage and "(i,j) -> (j,i)" requests column-wise storage.
|
||||||
|
- The required bit width for "pointer" storage (integral offsets into
|
||||||
|
the sparse storage scheme). A narrow width reduces the memory footprint
|
||||||
|
of overhead storage, as long as the width suffices to define the total
|
||||||
|
required range (viz. the maximum number of stored entries over all indirection
|
||||||
|
dimensions). The choices are `8`, `16`, `32`, `64`, or `0` for a native width.
|
||||||
|
- The required bit width for "index" storage (elements of the coordinates of
|
||||||
|
stored entries). A narrow width reduces the memory footprint of overhead
|
||||||
|
storage, as long as the width suffices to define the total required range
|
||||||
|
(viz. the maximum value of each tensor index over all dimensions). The
|
||||||
|
choices are `8`, `16`, `32`, `64`, or `0` for a native width.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```mlir
|
```mlir
|
||||||
|
@ -41,7 +63,6 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
|
||||||
indexBitWidth = 8
|
indexBitWidth = 8
|
||||||
}>
|
}>
|
||||||
|
|
||||||
|
|
||||||
... tensor<8x8xf64, #DCSC> ...
|
... tensor<8x8xf64, #DCSC> ...
|
||||||
```
|
```
|
||||||
}];
|
}];
|
||||||
|
@ -50,32 +71,16 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
|
||||||
let parameters = (
|
let parameters = (
|
||||||
ins
|
ins
|
||||||
// A dimension level type for each dimension of a tensor type.
|
// A dimension level type for each dimension of a tensor type.
|
||||||
// The choices are `dense` (dimension should be stored in its entirety),
|
|
||||||
// `compressed` (only non-zero regions or elements should be stored),
|
|
||||||
// or `singleton` (no sibling elements for parent).
|
|
||||||
ArrayRefParameter<
|
ArrayRefParameter<
|
||||||
"SparseTensorEncodingAttr::DimLevelType",
|
"SparseTensorEncodingAttr::DimLevelType",
|
||||||
"Per-dimension level type"
|
"Per-dimension level type (dense or compressed)"
|
||||||
>: $dimLevelType,
|
>: $dimLevelType,
|
||||||
// A dimension order on the indices of this tensor type.
|
// A dimension order on the indices of this tensor type.
|
||||||
// Unlike dense storage, most sparse storage schemes do not provide
|
|
||||||
// fast random access. This affine map specifies the order of
|
|
||||||
// dimensions that should be support by the sparse storage scheme
|
|
||||||
// (e.g. (i,j) -> (i,j) requests 2-d row-wise and (i,j) -> (j,i)
|
|
||||||
// requests 2-d column-wise storage).
|
|
||||||
// TODO: block structure with higher-dim inputs
|
// TODO: block structure with higher-dim inputs
|
||||||
"AffineMap":$dimOrdering,
|
"AffineMap":$dimOrdering,
|
||||||
// The required bit width for pointer storage. A narrow width reduces
|
// The required bit width for pointer storage.
|
||||||
// the memory footprint of overhead storage, as long as the width
|
|
||||||
// suffices to define the total required range (viz. the maximum
|
|
||||||
// number of stored entries over all indirection dimensions). The choices
|
|
||||||
// are `8`, `16`, `32`, `64`, or `0` for a native width.
|
|
||||||
"unsigned":$pointerBitWidth,
|
"unsigned":$pointerBitWidth,
|
||||||
// The required bit width for index storage. A narrow width reduces
|
// The required bit width for index storage.
|
||||||
// the memory footprint of overhead storage, as long as the width
|
|
||||||
// suffices to define the total required range (viz. the maximum
|
|
||||||
// value of each tensor index over all dimensions). The choices are `8`,
|
|
||||||
// `16`, `32`, `64`, or `0` for a native width.
|
|
||||||
"unsigned":$indexBitWidth
|
"unsigned":$indexBitWidth
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -83,9 +88,7 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
|
||||||
let hasCustomAssemblyFormat = 1;
|
let hasCustomAssemblyFormat = 1;
|
||||||
|
|
||||||
let extraClassDeclaration = [{
|
let extraClassDeclaration = [{
|
||||||
// Dimension level types that define sparse tensors:
|
// Dimension level types.
|
||||||
// Dense - dimension is dense, every entry is stored
|
|
||||||
// Compressed (unique) - dimension is sparse, only nonzeros are stored (no duplicates)
|
|
||||||
enum class DimLevelType {
|
enum class DimLevelType {
|
||||||
Dense, Compressed
|
Dense, Compressed
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue