Skip to content

Commit ced1fac

Browse files
[mlir][sparse] Move n:m printing into toMLIRString (llvm#84264)
1 parent 9cf9cb2 commit ced1fac

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ struct LevelType {
360360
std::string toMLIRString() const {
361361
std::string lvlStr = toFormatString(getLvlFmt());
362362
std::string propStr = "";
363+
if (isa<LevelFormat::NOutOfM>()) {
364+
lvlStr +=
365+
"[" + std::to_string(getN()) + ", " + std::to_string(getM()) + "]";
366+
}
363367
if (isa<LevelPropNonDefault::Nonunique>())
364368
propStr += toPropString(LevelPropNonDefault::Nonunique);
365369

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -646,28 +646,16 @@ void SparseTensorEncodingAttr::printDimensions(
646646
}
647647
}
648648

649-
std::string getNOutOfMString(LevelType lt) {
650-
if (isNOutOfMLT(lt)) {
651-
unsigned n = getN(lt);
652-
unsigned m = getM(lt);
653-
auto output = "[" + std::to_string(n) + ", " + std::to_string(m) + "]";
654-
return output;
655-
}
656-
return "";
657-
}
658-
659649
void SparseTensorEncodingAttr::printLevels(AffineMap &map, AsmPrinter &printer,
660650
ArrayRef<LevelType> lvlTypes) const {
661651
for (unsigned i = 0, n = map.getNumResults() - 1; i < n; i++) {
662652
map.getResult(i).print(printer.getStream());
663-
printer << " : " << toMLIRString(lvlTypes[i])
664-
<< getNOutOfMString(lvlTypes[i]) << ", ";
653+
printer << " : " << toMLIRString(lvlTypes[i]) << ", ";
665654
}
666655
if (map.getNumResults() >= 1) {
667656
auto lastIndex = map.getNumResults() - 1;
668657
map.getResult(lastIndex).print(printer.getStream());
669-
printer << " : " << toMLIRString(lvlTypes[lastIndex])
670-
<< getNOutOfMString(lvlTypes[lastIndex]);
658+
printer << " : " << toMLIRString(lvlTypes[lastIndex]);
671659
}
672660
}
673661

0 commit comments

Comments
 (0)