Skip to content
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

transformations: New varith-fuse-repeated-operands pass #3357

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

n-io
Copy link
Collaborator

@n-io n-io commented Oct 30, 2024

This PR rewrites

varith.add %n, %n, %n, %x

as

%three arith.constant 3
%three_n = arith.mulx %n, %three       // mulf or muli
%varith.add %three_n, %x

This is useful in particular when operating on tensors, in order to avoid repeatedly adding a large tensor to itself (we have such a case).

The number of repetitions minimally required to trigger fusion behaviour can be controlled via a flag (default=2).

@n-io n-io added the transformations Changes or adds a transformatio label Oct 30, 2024
@n-io n-io self-assigned this Oct 30, 2024
Copy link
Collaborator

@dk949 dk949 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good

@n-io n-io merged commit 63974ae into main Oct 31, 2024
13 checks passed
@n-io n-io deleted the nicolai/varith-fuse-operands branch October 31, 2024 10:43
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…3357)

This PR rewrites 
```
varith.add %n, %n, %n, %x
```
as
```
%three arith.constant 3
%three_n = arith.mulx %n, %three       // mulf or muli
%varith.add %three_n, %x
```

This is useful in particular when operating on tensors, in order to
avoid repeatedly adding a large tensor to itself (we have such a case).

The number of repetitions minimally required to trigger fusion behaviour
can be controlled via a flag (default=2).

Co-authored-by: n-io <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transformations Changes or adds a transformatio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants