[Mlir-commits] [mlir] fda1768 - [mlir][sparse] use new permutation utility to avoid codedup

Aart Bik llvmlistbot at llvm.org
Tue Aug 24 08:48:33 PDT 2021


Author: Aart Bik
Date: 2021-08-24T08:48:17-07:00
New Revision: fda176892e64b093996763465338863067e5b09e

URL: https://github.com/llvm/llvm-project/commit/fda176892e64b093996763465338863067e5b09e
DIFF: https://github.com/llvm/llvm-project/commit/fda176892e64b093996763465338863067e5b09e.diff

LOG: [mlir][sparse] use new permutation utility to avoid codedup

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D108636

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
index 9b55b777fbc8..3708345244f4 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp
@@ -244,16 +244,8 @@ class SparseTensorToDimSizeConverter
     if (!index.hasValue())
       return failure();
     int64_t idx = index.getValue();
-    AffineMap p = enc.getDimOrdering();
-    if (p) {
-      assert(p.isPermutation());
-      for (unsigned i = 0, sz = p.getNumResults(); i < sz; i++) {
-        if (p.getDimPosition(i) == idx) {
-          idx = i;
-          break;
-        }
-      }
-    }
+    if (AffineMap p = enc.getDimOrdering())
+      idx = p.getPermutedPosition(idx);
     // Generate the call.
     StringRef name = "sparseDimSize";
     SmallVector<Value, 2> params;


        


More information about the Mlir-commits mailing list