@@ -139,18 +139,19 @@ class SingletonLevel : public SparseLevel {
139
139
}
140
140
};
141
141
142
- class TwoOutFourLevel : public SparseLevel {
142
+ class NOutOfMLevel : public SparseLevel {
143
143
public:
144
- TwoOutFourLevel (unsigned tid, Level lvl, LevelType lt, Value lvlSize,
145
- Value crdBuffer)
144
+ NOutOfMLevel (unsigned tid, Level lvl, LevelType lt, Value lvlSize,
145
+ Value crdBuffer)
146
146
: SparseLevel(tid, lvl, lt, lvlSize, crdBuffer) {}
147
147
148
148
ValuePair peekRangeAt (OpBuilder &b, Location l, Value p,
149
149
Value max) const override {
150
- assert (max == nullptr && isUnique () && " 2:4 level can not be non-unique." );
151
- // Each 2:4 blk has exactly two specified elements.
152
- Value posLo = MULI (p, C_IDX (2 ));
153
- return {posLo, ADDI (posLo, C_IDX (2 ))};
150
+ assert (max == nullptr && isUnique () && " n:m level can not be non-unique." );
151
+ // Each n:m blk has exactly n specified elements.
152
+ auto n = getN (lt);
153
+ Value posLo = MULI (p, C_IDX (n));
154
+ return {posLo, ADDI (posLo, C_IDX (n))};
154
155
}
155
156
};
156
157
@@ -1293,7 +1294,7 @@ sparse_tensor::makeSparseTensorLevel(OpBuilder &b, Location l, Value t,
1293
1294
}
1294
1295
case LevelFormat::NOutOfM: {
1295
1296
Value crd = genToCoordinates (b, l, t, lvl);
1296
- return std::make_unique<TwoOutFourLevel >(tid, lvl, lt, sz, crd);
1297
+ return std::make_unique<NOutOfMLevel >(tid, lvl, lt, sz, crd);
1297
1298
}
1298
1299
}
1299
1300
llvm_unreachable (" unrecognizable level format" );
0 commit comments