[Mlir-commits] [mlir] [mlir][sparse] Populate lvlToDim (PR #68937)
Aart Bik
llvmlistbot at llvm.org
Mon Oct 16 10:14:05 PDT 2023
================
@@ -48,15 +48,17 @@ bool mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr) {
MlirAttribute
mlirSparseTensorEncodingAttrGet(MlirContext ctx, intptr_t lvlRank,
MlirSparseTensorDimLevelType const *lvlTypes,
- MlirAffineMap dimToLvl, int posWidth,
- int crdWidth) {
+ MlirAffineMap dimToLvl, MlirAffineMap lvlToDim,
+ int posWidth, int crdWidth) {
SmallVector<DimLevelType> cppLvlTypes;
cppLvlTypes.reserve(lvlRank);
for (intptr_t l = 0; l < lvlRank; ++l)
cppLvlTypes.push_back(static_cast<DimLevelType>(lvlTypes[l]));
- mlir::AffineMap lvlToDim; // TODO: provide in API
+ auto unwrappedLvlToDim = unwrap(lvlToDim);
+ if (!unwrappedLvlToDim)
+ unwrappedLvlToDim = inferLvlToDim(unwrap(dimToLvl), unwrap(ctx));
----------------
aartbik wrote:
I am not sure if we should infer inside the CAPI construction (which is really a binding to the outside world), or whether this should just mechanically accept whatever is given. If we do inference during construction, if feels this logic should be in SparseTensorEncodingAttr::get itself, not in the binding code
https://github.com/llvm/llvm-project/pull/68937
More information about the Mlir-commits
mailing list