@@ -106,35 +106,36 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
106
106
sparsity-agnostic representation of the computation, i.e., an implicit sparse
107
107
representation is converted to an explicit sparse representation where co-iterating
108
108
loops operate on sparse storage formats rather than tensors with a sparsity
109
- encoding. Compiler passes that run before this sparse compiler pass need to
110
- be aware of the semantics of tensor types with such a sparsity encoding.
109
+ encoding. Compiler passes that run before this sparsifier pass need to be aware
110
+ of the semantics of tensor types with such a sparsity encoding.
111
111
112
- In this encoding, we use ` dimension` to refer to the axes of the semantic tensor,
113
- and ` level` to refer to the axes of the actual storage format, i.e., the
112
+ In this encoding, we use ** dimension** to refer to the axes of the semantic tensor,
113
+ and ** level** to refer to the axes of the actual storage format, i.e., the
114
114
operational representation of the sparse tensor in memory. The number of
115
115
dimensions is usually the same as the number of levels (such as CSR storage format).
116
116
However, the encoding can also map dimensions to higher-order levels (for example,
117
117
to encode a block-sparse BSR storage format) or to lower-order levels
118
118
(for example, to linearize dimensions as a single level in the storage).
119
119
120
- The encoding contains a ` map` that provides the following:
120
+ The encoding contains a map that provides the following:
121
121
122
122
- An ordered sequence of dimension specifications, each of which defines:
123
123
- the dimension-size (implicit from the tensor’s dimension-shape)
124
124
- a **dimension-expression**
125
125
- An ordered sequence of level specifications, each of which includes a required
126
126
**level-type**, which defines how the level should be stored. Each level-type
127
127
consists of:
128
+ - a **level-expression**, which defines what is stored
128
129
- a **level-format**
129
130
- a collection of **level-properties** that apply to the level-format
130
- - a **level-expression**, which defines what is stored
131
131
132
132
Each level-expression is an affine expression over dimension-variables. Thus, the
133
133
level-expressions collectively define an affine map from dimension-coordinates to
134
134
level-coordinates. The dimension-expressions collectively define the inverse map,
135
135
which only needs to be provided for elaborate cases where it cannot be inferred
136
136
automatically. Within the sparse storage format, we refer to indices that are
137
- stored explicitly as `coordinates` and indices into the storage format as `positions`.
137
+ stored explicitly as **coordinates** and offsets into the storage format as
138
+ **positions**.
138
139
139
140
The supported level-formats are the following:
140
141
@@ -145,26 +146,26 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
145
146
Different level-formats may have different collections of level-properties.
146
147
By default, each level-type has the property of being unique (no duplicate
147
148
coordinates at that level), ordered (coordinates appear sorted at that
148
- level), and, for compression, storing the positions in a compact way where
149
- an interval is defined by a lower bound " pos(i)" and an upper bound " pos(i+1)-1" .
149
+ level), and, for compression, storing each position interval in a compact
150
+ way with a lowerbound ` pos(i)` " and an upperbound ` pos(i+1) - 1` .
150
151
The following properties can be added to a level-format to change this
151
152
default behavior:
152
153
153
154
- **nonunique** : duplicate coordinates may appear at the level
154
155
- **nonordered** : coordinates may appear in arbribratry order
155
- - **high** : the upper bound is stored explicitly in a separate array
156
+ - **high** : position interval upperbounds are stored explicitly
156
157
- **block2_4** : the compression uses a 2:4 encoding per 1x4 block
157
158
158
- In addition to the ` map` , the following two fields are optional:
159
+ In addition to the map, the following two fields are optional:
159
160
160
- - The required bitwidth for ` position` storage (integral offsets
161
+ - The required bitwidth for position storage (integral offsets
161
162
into the sparse storage scheme). A narrow width reduces the memory
162
163
footprint of overhead storage, as long as the width suffices to
163
164
define the total required range (viz. the maximum number of stored
164
165
entries over all indirection levels). The choices are `8`, `16`,
165
166
`32`, `64`, or, the default, `0` to indicate the native bitwidth.
166
167
167
- - The required bitwidth for ` coordinate` storage (the coordinates
168
+ - The required bitwidth for coordinate storage (the coordinates
168
169
of stored entries). A narrow width reduces the memory footprint
169
170
of overhead storage, as long as the width suffices to define
170
171
the total required range (viz. the maximum value of each tensor
@@ -231,20 +232,26 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
231
232
```
232
233
}];
233
234
235
+ //
234
236
// Data in sparse tensor encoding.
237
+ //
235
238
let parameters = (
236
239
ins
237
240
// A level-type for each level of the sparse storage.
238
241
ArrayRefParameter<
239
242
"::mlir::sparse_tensor::DimLevelType",
240
243
"level-types"
241
244
>: $lvlTypes,
245
+
242
246
// A mapping from dimension-coordinates to level-coordinates.
243
247
"AffineMap":$dimToLvl,
248
+
244
249
// The required bitwidth for position storage.
245
250
"unsigned":$posWidth,
251
+
246
252
// The required bitwidth for coordinate storage.
247
253
"unsigned":$crdWidth,
254
+
248
255
// A slice attribute for each dimension of the tensor type.
249
256
ArrayRefParameter<
250
257
"::mlir::sparse_tensor::SparseTensorDimSliceAttr",
0 commit comments