Skip to content

Commit 14d0cd6

Browse files
[mlir][sparse] Fix errors in doc and tests (#68641)
1 parent ac0dda8 commit 14d0cd6

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,11 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
133133
level-expressions collectively define an affine map from dimension-coordinates to
134134
level-coordinates. The dimension-expressions collectively define the inverse map,
135135
which only needs to be provided for elaborate cases where it cannot be inferred
136-
automatically. Within the sparse storage format, we refer to indices that are
137-
stored explicitly as **coordinates** and offsets into the storage format as
138-
**positions**.
136+
automatically.
137+
138+
Each dimension could also have an optional `SparseTensorDimSliceAttr`.
139+
Within the sparse storage format, we refer to indices that are stored explicitly
140+
as **coordinates** and offsets into the storage format as **positions**.
139141

140142
The supported level-formats are the following:
141143

@@ -176,9 +178,6 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
176178
coordinate over all levels). The choices are `8`, `16`, `32`,
177179
`64`, or, the default, `0` to indicate a native bitwidth.
178180

179-
- An optional array of `SparseTensorDimSliceAttr`, which specifies
180-
how the sparse tensor is partitioned on each dimension.
181-
182181
Examples:
183182

184183
```mlir
@@ -228,7 +227,8 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
228227
// Same block sparse row storage (2x3 blocks) but this time
229228
// also with a redundant reverse mapping, which can be inferred.
230229
#BSR_explicit = #sparse_tensor.encoding<{
231-
map = ( i = ib * 2 + ii,
230+
map = { ib, jb, ii, jj }
231+
( i = ib * 2 + ii,
232232
j = jb * 3 + jj) ->
233233
( ib = i floordiv 2 : dense,
234234
jb = j floordiv 3 : compressed,
@@ -265,7 +265,7 @@ def SparseTensorEncodingAttr : SparseTensor_Attr<"SparseTensorEncoding",
265265
j : #sparse_tensor<slice(0, 8, ?)>) ->
266266
(i : dense, j : compressed)
267267
}>
268-
... tensor<?x?xf64, #CSC_SLICE> ...
268+
... tensor<?x?xf64, #CSR_SLICE> ...
269269

270270
```
271271
}];

mlir/test/Dialect/SparseTensor/roundtrip_encoding.mlir

+15-15
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ func.func private @sparse_sorted_coo(tensor<10x10xf64, #SortedCOO>)
8484

8585
// -----
8686

87-
#BCSR = #sparse_tensor.encoding<{
87+
#BSR = #sparse_tensor.encoding<{
8888
map = ( i, j ) ->
89-
( i floordiv 2 : compressed,
89+
( i floordiv 2 : dense,
9090
j floordiv 3 : compressed,
9191
i mod 2 : dense,
9292
j mod 3 : dense
9393
)
9494
}>
9595

96-
// CHECK-LABEL: func private @sparse_bcsr(
97-
// CHECK-SAME: tensor<10x60xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : compressed, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
98-
func.func private @sparse_bcsr(tensor<10x60xf64, #BCSR>)
96+
// CHECK-LABEL: func private @sparse_bsr(
97+
// CHECK-SAME: tensor<10x60xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : dense, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
98+
func.func private @sparse_bsr(tensor<10x60xf64, #BSR>)
9999

100100

101101
// -----
@@ -143,39 +143,39 @@ func.func private @sparse_2_out_of_4(tensor<?x?xf64, #NV_24>)
143143

144144
// -----
145145

146-
#BCSR = #sparse_tensor.encoding<{
146+
#BSR = #sparse_tensor.encoding<{
147147
map = ( i, j ) ->
148-
( i floordiv 2 : compressed,
148+
( i floordiv 2 : dense,
149149
j floordiv 3 : compressed,
150150
i mod 2 : dense,
151151
j mod 3 : dense
152152
)
153153
}>
154154

155-
// CHECK-LABEL: func private @BCSR(
156-
// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : compressed, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
157-
func.func private @BCSR(%arg0: tensor<?x?xf64, #BCSR>) {
155+
// CHECK-LABEL: func private @BSR(
156+
// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : dense, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
157+
func.func private @BSR(%arg0: tensor<?x?xf64, #BSR>) {
158158
return
159159
}
160160

161161
// -----
162162

163-
#BCSR_explicit = #sparse_tensor.encoding<{
163+
#BSR_explicit = #sparse_tensor.encoding<{
164164
map =
165165
{il, jl, ii, jj}
166166
( i = il * 2 + ii,
167167
j = jl * 3 + jj
168168
) ->
169-
( il = i floordiv 2 : compressed,
169+
( il = i floordiv 2 : dense,
170170
jl = j floordiv 3 : compressed,
171171
ii = i mod 2 : dense,
172172
jj = j mod 3 : dense
173173
)
174174
}>
175175

176-
// CHECK-LABEL: func private @BCSR_explicit(
177-
// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : compressed, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
178-
func.func private @BCSR_explicit(%arg0: tensor<?x?xf64, #BCSR_explicit>) {
176+
// CHECK-LABEL: func private @BSR_explicit(
177+
// CHECK-SAME: tensor<?x?xf64, #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 floordiv 2 : dense, d1 floordiv 3 : compressed, d0 mod 2 : dense, d1 mod 3 : dense) }>>
178+
func.func private @BSR_explicit(%arg0: tensor<?x?xf64, #BSR_explicit>) {
179179
return
180180
}
181181

0 commit comments

Comments
 (0)