Skip to content

Commit fda1768

Browse files
committed
[mlir][sparse] use new permutation utility to avoid codedup
Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D108636
1 parent 307890f commit fda1768

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,8 @@ class SparseTensorToDimSizeConverter
244244
if (!index.hasValue())
245245
return failure();
246246
int64_t idx = index.getValue();
247-
AffineMap p = enc.getDimOrdering();
248-
if (p) {
249-
assert(p.isPermutation());
250-
for (unsigned i = 0, sz = p.getNumResults(); i < sz; i++) {
251-
if (p.getDimPosition(i) == idx) {
252-
idx = i;
253-
break;
254-
}
255-
}
256-
}
247+
if (AffineMap p = enc.getDimOrdering())
248+
idx = p.getPermutedPosition(idx);
257249
// Generate the call.
258250
StringRef name = "sparseDimSize";
259251
SmallVector<Value, 2> params;

0 commit comments

Comments
 (0)