// Create buffer allocation.
Value alloc =
createAllocationForTensor(rewriter, loc, padOp.getResult(), memorySpace);
+ rewriter.setInsertionPointAfter(alloc.getDefiningOp());
// Create linalg.fill or linalg.generic.
Operation *fillOp = movePaddingToFillOrGenericOp(rewriter, loc, padOp, alloc);
if (auto bbArg = value.dyn_cast<BlockArgument>()) {
rewriter.setInsertionPointToStart(bbArg.getOwner());
} else {
- rewriter.setInsertionPoint(value.getDefiningOp());
+ rewriter.setInsertionPointAfter(value.getDefiningOp());
}
Location loc = value.getLoc();
Value alloc = createAllocationForTensor(rewriter, loc, value, memorySpace);
// Create memref.tensor_store.
+ rewriter.setInsertionPointAfter(alloc.getDefiningOp());
rewriter.create<memref::TensorStoreOp>(loc, value, alloc);
// Create bufferization.to_tensor with "restrict" and "writable". The returned
// Make sure that One-Shot Bufferize can bufferize the rest.
transform.bufferization.one_shot_bufferize %arg1
}
+
+// -----
+
+// CHECK-LABEL: func @materialization_of_opresult(
+// CHECK: %[[t:.*]] = "dummy.some_op"
+// CHECK: %[[alloc:.*]] = memref.alloc(%{{.*}}) : memref<?x10xindex, 4>
+// CHECK: memref.tensor_store %[[t]], %[[alloc]]
+// CHECK: %[[r:.*]] = bufferization.to_tensor %[[alloc]]
+// CHECK: return %[[r]]
+func.func @materialization_of_opresult(%idx: index) -> tensor<?x10xindex> {
+ %t = "dummy.some_op"() : () -> (tensor<?x10xindex>)
+ return %t : tensor<?x10xindex>
+}
+
+transform.sequence failures(propagate) {
+^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["dummy.some_op"]} in %arg1 : (!pdl.operation) -> !pdl.operation
+ %1 = transform.get_result %0[0] : (!pdl.operation) -> !transform.any_value
+ %2 = transform.structured.bufferize_to_allocation %1 {memory_space = 4}
+}
+
+