From 8e911b4d4ea069ed0e8e4fc6bdc005106e990418 Mon Sep 17 00:00:00 2001 From: n-io Date: Fri, 20 Dec 2024 16:16:16 +0100 Subject: [PATCH] transformations: (csl-stencil-bufferize) AccessOp to read to_tensors underlying memref --- xdsl/transforms/csl_stencil_bufferize.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xdsl/transforms/csl_stencil_bufferize.py b/xdsl/transforms/csl_stencil_bufferize.py index bd4f46d9fe..add9764e36 100644 --- a/xdsl/transforms/csl_stencil_bufferize.py +++ b/xdsl/transforms/csl_stencil_bufferize.py @@ -289,10 +289,18 @@ def match_and_rewrite(self, op: csl_stencil.AccessOp, rewriter: PatternRewriter, rewriter.replace_matched_op(to_tensor_op(op.op)) return + # accesses to buffers passed in additional args can read directly from memref underlying `to_tensor` + source = ( + op.op.op.memref + if isinstance(op.op, OpResult) + and isinstance(op.op.op, bufferization.ToTensorOp) + else op.op + ) + rewriter.replace_matched_op( [ access := csl_stencil.AccessOp( - op.op, + source, op.offset, r_type, op.offset_mapping,