[Mlir-commits] [mlir] [mlir][sparse] Update verifier for block sparsity and singleton (PR #69389)
Yinying Li
llvmlistbot at llvm.org
Wed Oct 18 13:07:58 PDT 2023
================
@@ -818,6 +824,53 @@ AffineMap mlir::sparse_tensor::inverseBlockSparsity(AffineMap dimToLvl,
return dimToLvl.get(dimToLvl.getNumResults(), 0, lvlExprs, context);
}
+SmallVector<unsigned> mlir::sparse_tensor::getBlockSize(AffineMap dimToLvl) {
+ assert(isBlockSparsity(dimToLvl) &&
+ "expected dimToLvl to be block sparsity for calling getBlockSize");
+ SmallVector<unsigned> blockSize;
+ for (auto result : dimToLvl.getResults()) {
+ if (auto binOp = result.dyn_cast<AffineBinaryOpExpr>()) {
+ if (result.getKind() == AffineExprKind::Mod) {
+ blockSize.push_back(
+ binOp.getRHS().dyn_cast<AffineConstantExpr>().getValue());
+ }
+ } else {
+ blockSize.push_back(1);
----------------
yinying-lisa-li wrote:
Yeah, that's true. But how should we handle cases for 2:4 like below? It's technically 1x4 so block size for `i` should be 1?
#NV_24 = #sparse_tensor.encoding<{
map = ( i, j ) ->
( i : dense,
j floordiv 4 : dense,
j mod 4 : block2_4
)
}>
https://github.com/llvm/llvm-project/pull/69389
More information about the Mlir-commits
mailing list