[Mlir-commits] [mlir] c3160f8 - [mlir][sparse] Fix bug in new syntax parser (#66024)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 11 16:13:20 PDT 2023
Author: yinying-lisa-li
Date: 2023-09-11T19:13:15-04:00
New Revision: c3160f86e7063431d7366d7d264330caf61c0b09
URL: https://github.com/llvm/llvm-project/commit/c3160f86e7063431d7366d7d264330caf61c0b09
DIFF: https://github.com/llvm/llvm-project/commit/c3160f86e7063431d7366d7d264330caf61c0b09.diff
LOG: [mlir][sparse] Fix bug in new syntax parser (#66024)
Currently, dimlvlmap with identity affine map will be treated as empty
affine map. But the new syntax would treat it as an actual identity
affine map such as {d0} -> {d0}. This mismatch could raise an error when
we are comparing sparse encodings.
Added:
Modified:
mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp b/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp
index 81302f200f686bb..05fce96043826f1 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMap.cpp
@@ -348,7 +348,9 @@ AffineMap DimLvlMap::getDimToLvlMap(MLIRContext *context) const {
lvlAffines.reserve(getLvlRank());
for (const auto &lvlSpec : lvlSpecs)
lvlAffines.push_back(lvlSpec.getExpr().getAffineExpr());
- return AffineMap::get(getDimRank(), getSymRank(), lvlAffines, context);
+ auto map = AffineMap::get(getDimRank(), getSymRank(), lvlAffines, context);
+ if (map.isIdentity()) return AffineMap();
+ return map;
}
AffineMap DimLvlMap::getLvlToDimMap(MLIRContext *context) const {
@@ -356,7 +358,9 @@ AffineMap DimLvlMap::getLvlToDimMap(MLIRContext *context) const {
dimAffines.reserve(getDimRank());
for (const auto &dimSpec : dimSpecs)
dimAffines.push_back(dimSpec.getExpr().getAffineExpr());
- return AffineMap::get(getLvlRank(), getSymRank(), dimAffines, context);
+ auto map = AffineMap::get(getLvlRank(), getSymRank(), dimAffines, context);
+ if (map.isIdentity()) return AffineMap();
+ return map;
}
void DimLvlMap::dump() const {
More information about the Mlir-commits
mailing list