Skip to content

Commit bfefa15

Browse files
authored
[mlir][bufferization] Use original type when convert arg for users (#124826)
This change will keep the memory space information for the tensor if there is any.
1 parent b197268 commit bfefa15

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,15 @@ bufferization::bufferizeBlockSignature(Block *block, RewriterBase &rewriter,
453453
for (OpOperand &use : bbArg.getUses())
454454
bbArgUses.push_back(&use);
455455

456+
Type tensorType = bbArg.getType();
456457
// Change the bbArg type to memref.
457458
bbArg.setType(type);
458459

459460
// Replace all uses of the original tensor bbArg.
460461
rewriter.setInsertionPointToStart(block);
461462
if (!bbArgUses.empty()) {
462-
Value toTensorOp =
463-
rewriter.create<bufferization::ToTensorOp>(bbArg.getLoc(), bbArg);
463+
Value toTensorOp = rewriter.create<bufferization::ToTensorOp>(
464+
bbArg.getLoc(), tensorType, bbArg);
464465
for (OpOperand *use : bbArgUses)
465466
use->set(toTensorOp);
466467
}

0 commit comments

Comments
 (0)