diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -499,7 +499,10 @@ } cooBuffer = rewriter.create(loc, cooBuffer, true); - rewriter.replaceOpWithNewOp(op, rtp, cooBuffer); + Value converted = + rewriter.create(loc, rtp, cooBuffer).getResult(); + rewriter.create(loc, cooBuffer); + rewriter.replaceOp(op, converted); return success(); } };