Skip to content

Commit c731e56

Browse files
block coefficients verification
1 parent 86d9f1b commit c731e56

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ LogicalResult SparseTensorEncodingAttr::verify(
666666
[](LevelType i) { return isDenseLT(i); }))
667667
return emitError() << "expected all dense lvlTypes "
668668
"before a n_out_of_m level";
669-
670669
if (dimToLvl && (dimToLvl.getNumDims() != dimToLvl.getNumResults())) {
671670
if (!isBlockSparsity(dimToLvl)) {
672671
return emitError()
@@ -675,10 +674,11 @@ LogicalResult SparseTensorEncodingAttr::verify(
675674
auto sizes = getBlockSize(dimToLvl);
676675
unsigned coefficient = 0;
677676
for (const auto &elem : sizes) {
678-
if (elem != 0 && coefficient != 0) {
679-
return emitError() << "expected only one blocked level with the same "
680-
"coefficients";
681-
} else {
677+
if (elem != 0) {
678+
if (elem != coefficient && coefficient != 0) {
679+
return emitError() << "expected only one blocked level "
680+
"with the same coefficients";
681+
}
682682
coefficient = elem;
683683
}
684684
}

mlir/test/Dialect/SparseTensor/invalid_encoding.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ func.func private @NOutOfM(%arg0: tensor<?x?x?xf64, #NOutOfM>) {
378378

379379
// -----
380380

381-
// expected-error@+1 {{expected 1xm block structure for n_out_of_m_level}}
381+
// expected-error@+1 {{expected 1xm block structure for n_out_of_m level}}
382382
#NOutOfM = #sparse_tensor.encoding<{
383383
map = ( i, j, k ) ->
384384
( i : dense,

0 commit comments

Comments
 (0)