-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add expand-copy pass that expands memref.copy as a nested structure o… #3452
base: main
Are you sure you want to change the base?
Conversation
|
||
def apply(self, ctx: MLContext, op: builtin.ModuleOp) -> None: | ||
expand_copy_pass = PatternRewriteWalker( | ||
GreedyRewritePatternApplier([ExpandCopy()]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a need for the greedy applier if it's just one rewrite
) | ||
for_indices.append(args[0]) | ||
|
||
symbols = list(map(lambda dim: AffineExpr.dimension(dim), range(ndims))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend list/tuple comprehensions over map these days, they're noticeably faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, why not :) But would definitely be great for it to be well-tested. Out of curiosity, what will you be using it for?
…f affine for loops
Just latency estimation in terms of clock cycles. Strictly speaking I wouldn't need this pass to do that, but the tool I'm using works on the affine dialect, so it was easier writing this pass than changing the tool. |
Then I will apply your comments and include tests in the following days :) @superlopuh . |
Pass that expands memref.copy as a nested structure of affine for loops with load/store. This is a functional port of the expand-copy pass in Google's HEIR: https://heir.dev/docs/passes/#-expand-copy.
Not sure if this is interesting for the community, but is something I needed for my own work. If it is, I will provide tests soon.