Skip to content

Commit 329c64c

Browse files
authored
[mlir][sparse] update BSR specification (#67480)
Makes outer level dense, so we get the common block-column index way of storing blocks. Also gives an example of a dim2lvl/lvl2dim map.
1 parent 6dfdf68 commit 329c64c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,26 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
217217
// Block sparse row storage (2x3 blocks).
218218
#BSR = #sparse_tensor.encoding<{
219219
map = ( i, j ) ->
220-
( i floordiv 2 : compressed,
220+
( i floordiv 2 : dense,
221221
j floordiv 3 : compressed,
222222
i mod 2 : dense,
223223
j mod 3 : dense
224224
)
225225
}>
226226
... tensor<20x30xf32, #BSR> ...
227227

228+
// Same block sparse row storage (2x3 blocks) but this time
229+
// also with a redundant reverse mapping, which can be inferred.
230+
#BSR_explicit = #sparse_tensor.encoding<{
231+
map = ( i = ib * 2 + ii,
232+
j = jb * 3 + jj) ->
233+
( ib = i floordiv 2 : dense,
234+
jb = j floordiv 3 : compressed,
235+
ii = i mod 2 : dense,
236+
jj = j mod 3 : dense)
237+
}>
238+
... tensor<20x30xf32, #BSR_explicit> ...
239+
228240
// CSR slice (offset = 0, size = 4, stride = 1 on the first dimension;
229241
// offset = 0, size = 8, and a dynamic stride on the second dimension).
230242
#CSR_SLICE = #sparse_tensor.encoding<{

0 commit comments

Comments
 (0)