[Mlir-commits] [mlir] [mlir][sparse] implement loose-compressed/2:4 on direct IR codegen path (PR #71461)
Peiming Liu
llvmlistbot at llvm.org
Mon Nov 6 16:46:50 PST 2023
================
@@ -483,33 +484,37 @@ class SparseInsertGenerator
Value value = args.back();
Value parentPos = constantZero(builder, loc, builder.getIndexType());
// Generate code for every level.
- for (Level l = 0; l < lvlRank; l++) {
- const auto dlt = stt.getLvlType(l);
- if (isCompressedDLT(dlt)) {
+ for (Level lvl = 0; lvl < lvlRank; lvl++) {
+ const auto dlt = stt.getLvlType(lvl);
+ if (isCompressedDLT(dlt) || isLooseCompressedDLT(dlt)) {
// Create:
// if (!present) {
- // coordinates[l].push_back(coords[l])
- // <update positions and prepare level l + 1>
+ // coordinates[lvl].push_back(coords[lvl])
+ // <update positions and prepare level lvl + 1>
// }
- // positions[l] = coordinates.size() - 1
- // <insert @ positions[l] at next level l + 1>
+ // positions[lvl] = coordinates.size() - 1
+ // <insert @ positions[lvl] at next level lvl + 1>
+ if (isLooseCompressedDLT(dlt)) {
+ Value two = constantIndex(builder, loc, 2);
+ parentPos = builder.create<arith::MulIOp>(loc, parentPos, two);
+ }
parentPos =
- genCompressed(builder, loc, desc, coords, value, parentPos, l);
- } else if (isSingletonDLT(dlt)) {
+ genCompressed(builder, loc, desc, coords, value, parentPos, lvl);
+ } else if (isSingletonDLT(dlt) || is2OutOf4DLT(dlt)) {
----------------
PeimingLiu wrote:
Wow! that is it?!
https://github.com/llvm/llvm-project/pull/71461
More information about the Mlir-commits
mailing list