-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Refactor dot
op's CPU kernel for better performance
#32589
Conversation
Thanks for your contribution! |
Sorry to inform you that 988c1d1's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
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.
LGTM
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.
LGTM for op benchmark ci
PR types
Performance optimization
PR changes
OPs
Describe
Rewrote the
dot
op's CPU kernel and saw over 10x performance improvement.The main part of the kernel is a trivial loop nest performing a sequence of sum-reduces. Though the code is simple the branch in the inner loop is trouble enough to stop many types of loop optimization. Moreover, the reduction operation (+=) to a heap dereferenced value cannot be automatically localized. We have to do that manually.
Following compares IRs of the inner loop before and after the rewrite.
Before rewrite
After rewrite:
It's easy to see that the compiler successfully vectorized the loop.