Skip to content

Commit bf3a4e8

Browse files
noutofm level
1 parent 8ed3291 commit bf3a4e8

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorLevel.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,19 @@ class SingletonLevel : public SparseLevel {
139139
}
140140
};
141141

142-
class TwoOutFourLevel : public SparseLevel {
142+
class NOutOfMLevel : public SparseLevel {
143143
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)
146146
: SparseLevel(tid, lvl, lt, lvlSize, crdBuffer) {}
147147

148148
ValuePair peekRangeAt(OpBuilder &b, Location l, Value p,
149149
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))};
154155
}
155156
};
156157

@@ -1293,7 +1294,7 @@ sparse_tensor::makeSparseTensorLevel(OpBuilder &b, Location l, Value t,
12931294
}
12941295
case LevelFormat::NOutOfM: {
12951296
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);
12971298
}
12981299
}
12991300
llvm_unreachable("unrecognizable level format");

0 commit comments

Comments
 (0)