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

Fold fill into max #954

Merged
merged 5 commits into from
Aug 8, 2024
Merged

Fold fill into max #954

merged 5 commits into from
Aug 8, 2024

Conversation

adam-smnk
Copy link
Collaborator

Adds pattern that folds linalg.fill into linalg.max and outputs combined linalg.generic.

A constant filled buffer is replaced by a single constant used directly in max operation on the elements of the other operand.
This allows to eliminate potential temporary buffer allocation and value initialization.

@adam-smnk adam-smnk added the benchmark Triggers benchmark jobs label Aug 8, 2024
@adam-smnk adam-smnk requested a review from rengolin August 8, 2024 10:40
@adam-smnk adam-smnk added benchmark Triggers benchmark jobs and removed benchmark Triggers benchmark jobs labels Aug 8, 2024
Copy link
Contributor

@rengolin rengolin left a comment

Choose a reason for hiding this comment

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

Why is this restricted to max and not just any element-wise op?

@adam-smnk
Copy link
Collaborator Author

Why is this restricted to max and not just any element-wise op?

I think this could be easily relax to all named ops. Processing generics is also doable but hassle.
All in all, I just didn't want to bother for now.

@adam-smnk
Copy link
Collaborator Author

adam-smnk commented Aug 8, 2024

Fill folding together with broadcast folding finally improves named ops benchmarks.
The remaining slowdown is caused by one more temporary buffer allocation. It is most likely caused by the folded max generic which is not in in-place format (outs to tensor.empty). The next step is to rewrite the max generic in the same way as we do with linalg-convert-add-in-place for generic adds.

@adam-smnk
Copy link
Collaborator Author

Looks like the two folders could be merged, it just requires more testing to see if I missed any edge cases.
I'll follow up on that a bit later.

@adam-smnk adam-smnk merged commit 2425032 into plaidml:main Aug 8, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
benchmark Triggers benchmark jobs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants