[mlir][sparse] change variable dimension to fixed attribute pointers/indices

The "sparsification" pass does not need the ability to use runtime values for
the dimension, so the only source for variability would have been user code.
Restricting the dimension to constants simplifies code generation.

Reviewed By: Peiming, wrengr

Differential Revision: https://reviews.llvm.org/D133458
This commit is contained in:
Aart Bik
2022-09-07 15:08:29 -07:00
parent bb6966aa53
commit 610b09074a
34 changed files with 430 additions and 479 deletions

View File

@@ -1077,8 +1077,10 @@ public:
Type resType = op.getType();
Type ptrType = resType.cast<ShapedType>().getElementType();
SmallString<16> name{"sparsePointers", overheadTypeFunctionSuffix(ptrType)};
replaceOpWithFuncCall(rewriter, op, name, resType, adaptor.getOperands(),
EmitCInterface::On);
Value dim =
constantIndex(rewriter, op->getLoc(), op.getDimension().getZExtValue());
replaceOpWithFuncCall(rewriter, op, name, resType,
{adaptor.getTensor(), dim}, EmitCInterface::On);
return success();
}
};
@@ -1093,8 +1095,10 @@ public:
Type resType = op.getType();
Type indType = resType.cast<ShapedType>().getElementType();
SmallString<15> name{"sparseIndices", overheadTypeFunctionSuffix(indType)};
replaceOpWithFuncCall(rewriter, op, name, resType, adaptor.getOperands(),
EmitCInterface::On);
Value dim =
constantIndex(rewriter, op->getLoc(), op.getDimension().getZExtValue());
replaceOpWithFuncCall(rewriter, op, name, resType,
{adaptor.getTensor(), dim}, EmitCInterface::On);
return success();
}
};