Skip to content

Commit

Permalink
transformations: (csl-stencil-bufferize) AccessOp to read to_tensor's…
Browse files Browse the repository at this point in the history
… underlying memref (#3663)

`csl_stencil.AccessOp`s can read directly from memrefs underlying any
`bufferization.to_tensor` passed into them.

Currently, in the presence of several buffers (ie, stencil fields
translated to memrefs at this stage), all but the main buffer will have
intermediate `bufferization.to_tensor` ops, which creates problems in
lowering. The AccessOps can instead work directly off of the underlying
memrefs.

Co-authored-by: n-io <n-io@users.noreply.github.com>
  • Loading branch information
n-io and n-io authored Dec 20, 2024
1 parent 753ae32 commit e5e9069
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion xdsl/transforms/csl_stencil_bufferize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e5e9069

Please sign in to comment.