[mlir][sparse] Print new syntax (#68130)

Printing changes from `#sparse_tensor.encoding<{ lvlTypes = [
"compressed" ] }>` to `map = (d0) -> (d0 : compressed)`. Level
properties, ELL and slice are also supported.
This commit is contained in:
Yinying Li
2023-10-04 20:36:05 +00:00
committed by GitHub
parent 7794e16b49
commit 6280e23124
9 changed files with 116 additions and 65 deletions

View File

@@ -472,8 +472,17 @@ public:
llvm::raw_svector_ostream nameOstream(nameBuffer);
nameOstream << kInsertFuncNamePrefix;
const Level lvlRank = stt.getLvlRank();
for (Level l = 0; l < lvlRank; l++)
nameOstream << toMLIRString(stt.getLvlType(l)) << "_";
for (Level l = 0; l < lvlRank; l++) {
std::string lvlType = toMLIRString(stt.getLvlType(l));
// Replace/remove punctuations in level properties.
std::replace_if(
lvlType.begin(), lvlType.end(),
[](char c) { return c == '(' || c == ','; }, '_');
lvlType.erase(std::remove_if(lvlType.begin(), lvlType.end(),
[](char c) { return c == ')' || c == ' '; }),
lvlType.end());
nameOstream << lvlType << "_";
}
// Static dim sizes are used in the generated code while dynamic sizes are
// loaded from the dimSizes buffer. This is the reason for adding the shape
// to the function name.