Skip to content

Commit 88e3073

Browse files
format
1 parent 79e660c commit 88e3073

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ constexpr bool isValidNOutOfMLT(LevelType lt, uint64_t n, uint64_t m) {
233233
}
234234

235235
/// Returns string representation of the given dimension level type.
236-
std::string toMLIRString(LevelType lt) {
236+
constexpr const char *toMLIRString(LevelType lt) {
237237
switch (lt) {
238238
case LevelType::Undef:
239239
return "undef";
@@ -264,12 +264,8 @@ std::string toMLIRString(LevelType lt) {
264264
case LevelType::LooseCompressedNuNo:
265265
return "loose_compressed(nonunique, nonordered)";
266266
default:
267-
// If NOutOfM bit is set, print the [n, m] sizes.
268267
if (isNOutOfMLT(lt)) {
269-
unsigned n = getN(lt);
270-
unsigned m = getM(lt);
271-
return std::string("block[") + std::to_string(n) + ", " +
272-
std::to_string(m) + "]";
268+
return "block";
273269
}
274270
}
275271
return "";

mlir/lib/Dialect/SparseTensor/IR/Detail/DimLvlMapParser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ ParseResult DimLvlMapParser::parseLvlSpec(bool requireLvlVarBinding) {
299299
FAILURE_IF_FAILED(type)
300300

301301
lvlSpecs.emplace_back(var, expr, static_cast<LevelType>(*type));
302-
llvm::errs() << "type = " << toMLIRString(static_cast<LevelType>(*type))
303-
<< "\n";
304302
return success();
305303
}
306304

mlir/lib/Dialect/SparseTensor/IR/Detail/LvlTypeParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ FailureOr<uint64_t> LvlTypeParser::parseLvlType(AsmParser &parser) const {
6363
}
6464
properties |= static_cast<uint64_t>(LevelFormat::NOutOfM);
6565
properties |= nToBits(blockSizes[0]) | mToBits(blockSizes[1]);
66-
llvm::errs() << "properties1: " << properties << "\n";
6766
} else if (base.compare("loose_compressed") == 0) {
6867
properties |= static_cast<uint64_t>(LevelFormat::LooseCompressed);
6968
} else if (base.compare("singleton") == 0) {

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,16 +613,28 @@ void SparseTensorEncodingAttr::printDimensions(
613613
}
614614
}
615615

616+
std::string getNOutOfMString(LevelType lt) {
617+
if (isNOutOfMLT(lt)) {
618+
unsigned n = getN(lt);
619+
unsigned m = getM(lt);
620+
auto output = "[" + std::to_string(n) + ", " + std::to_string(m) + "]";
621+
return output;
622+
}
623+
return "";
624+
}
625+
616626
void SparseTensorEncodingAttr::printLevels(AffineMap &map, AsmPrinter &printer,
617627
ArrayRef<LevelType> lvlTypes) const {
618628
for (unsigned i = 0, n = map.getNumResults() - 1; i < n; i++) {
619629
map.getResult(i).print(printer.getStream());
620-
printer << " : " << toMLIRString(lvlTypes[i]) << ", ";
630+
printer << " : " << toMLIRString(lvlTypes[i])
631+
<< getNOutOfMString(lvlTypes[i]) << ", ";
621632
}
622633
if (map.getNumResults() >= 1) {
623634
auto lastIndex = map.getNumResults() - 1;
624635
map.getResult(lastIndex).print(printer.getStream());
625-
printer << " : " << toMLIRString(lvlTypes[lastIndex]);
636+
printer << " : " << toMLIRString(lvlTypes[lastIndex])
637+
<< getNOutOfMString(lvlTypes[lastIndex]);
626638
}
627639
}
628640

0 commit comments

Comments
 (0)