-
Notifications
You must be signed in to change notification settings - Fork 54
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
heat.pow()
speed-up when exponent is int
#1141
Conversation
Thank you for the PR! |
Codecov Report
@@ Coverage Diff @@
## main #1141 +/- ##
==========================================
+ Coverage 91.77% 91.79% +0.01%
==========================================
Files 72 72
Lines 10485 10497 +12
==========================================
+ Hits 9623 9636 +13
+ Misses 862 861 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thank you for the PR! |
|
Thanks @mtar.
floats exponents will be dealt with in the general __binary_op(), torch.pow() optimization for integer exponents makes for a significant speedup, see table above.
Turns out many binary operations in torch require both inputs to be tensors, so we need to wrap the ints into DNDarrays in those cases. |
Thank you for the PR! |
1 similar comment
Thank you for the PR! |
Thank you for the PR! |
Thank you for the PR! |
Fix broken link |
Description
This PR exploits
torch.pow(a,b)
's performance whenb
is an integer. For a torch/heat performance comparison (on 1 process) for a few binary operations, see table below.The problem was identified by @coquelin77 in #789 and #793. This PR replaces #793 which had gotten quite stale and difficult to update. Thanks again @coquelin77 for all the work.
Issue/s resolved: #789
Changes proposed:
InIn_operations.__binary_op
arithmetics.pow
: introduce an early check for integer scalar terms, perform the torch operation immediately without further checks and return results.Type of change
Memory requirements
NA
Performance
a = randn(10000, 10000)
(float64 torch tensor or float64 DNDarray respectively)main
1 proc789-pow
1 procDue Diligence
Does this change modify the behaviour of other functions? If so, which?
no