[Mlir-commits] [mlir] [mlir][SparseTensor] handle uninitialized transMap when translating shape (PR #195506)
Aart Bik
llvmlistbot at llvm.org
Mon May 4 08:58:07 PDT 2026
================
@@ -633,14 +633,13 @@ struct TensorAllocDemapper : public OpRewritePattern<AllocOp> {
}
assert(dynSz.empty()); // should have consumed all.
- rewriter.startOpModification(op);
- op->setOperands(dynLvlSzs);
- op.getResult().setType(stt.getDemappedType());
- rewriter.finalizeOpModification(op);
- rewriter.setInsertionPointAfter(op);
- Value t = genRemap(rewriter, stt.getEncoding(), op.getResult());
- rewriter.replaceAllUsesExcept(op.getResult(), t, t.getDefiningOp());
+ // create a new op to let the MLIR builder calculate the correct metadata.
+ auto allocOp = bufferization::AllocTensorOp::create(
+ rewriter, loc, stt.getDemappedType(), dynLvlSzs);
+
+ Value t = genRemap(rewriter, stt.getEncoding(), allocOp.getResult());
+ rewriter.replaceOp(op, t);
----------------
aartbik wrote:
This is actually a bit change compared to the original that i don't quite understand, it it not possible to keep the old replacement, what metadata is recomputed?
https://github.com/llvm/llvm-project/pull/195506
More information about the Mlir-commits
mailing list