[Mlir-commits] [mlir] [mlir][sparse] Populate lvlToDim (PR #68937)

Aart Bik llvmlistbot at llvm.org
Tue Oct 17 10:28:11 PDT 2023


================
@@ -749,6 +749,74 @@ mlir::sparse_tensor::getSparseTensorEncoding(Type type) {
   return nullptr;
 }
 
+AffineMap mlir::sparse_tensor::inferLvlToDim(AffineMap dimToLvl,
+                                             MLIRContext *context) {
+  auto map = static_cast<AffineMap>(dimToLvl);
+  AffineMap lvlToDim;
+  // Return an empty lvlToDim when inference is not successful.
+  if (!map || map.getNumSymbols() != 0) {
+    lvlToDim = AffineMap();
+  } else if (map.isPermutation()) {
+    lvlToDim = inversePermutation(map);
+  } else {
----------------
aartbik wrote:

Perhaps add a TODO to make this

else if (map.isBlock()) // pseudo-code but you get the idea
  lvlToDim = inverseBlockSparsity(map, context);
} else {
  // handle the error somehow
}

https://github.com/llvm/llvm-project/pull/68937


More information about the Mlir-commits mailing list