-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add _foreach_addc(div/mul)(_).Tensor #88157
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/88157
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit 1fedef8: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
test/test_foreach.py
Outdated
| for scalar in Scalars: | ||
| self._test_pointwise_op(device, dtype, op, N, True, disable_fastpath, values=scalar) | ||
| for _, scalarlist in getScalarLists(N): | ||
| self._test_pointwise_op(device, dtype, op, N, True, disable_fastpath, values=torch.tensor(scalar)) |
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.
Should you also test the case where torch.tensor(scalar, device=device) ?
Same for all the updates below.
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.
Yes, we'll need to add more "assertRegexFail" type tests
| CUDA: foreach_tensor_addcdiv_scalarlist_cuda_ | ||
| autogen: _foreach_addcdiv.ScalarList_out | ||
|
|
||
| - func: _foreach_addcdiv_.Tensor(Tensor(a!)[] self, Tensor[] tensor1, Tensor[] tensor2, Tensor scalars) -> () |
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.
Curious why this is not Tensor[] scalars? That sounds more consistent?
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.
Because those are more difficult to convert to scalars efficiently.
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.
At least, #88173 will pass Tensor[] to this according to the temporary code in there.
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.
Well it can convert the step sizes to a torch.Tensor before calling into foreach
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.
Doing a .cat() before every call sounds like a big overhead?
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.
It's for 1-element tensors on cpu only, should be fast.
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
albanD
left a comment
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.
Sounds good!
Support passing value scalars as a flat 1D Tensor. Currently we can only pass either an individual scalar or a ScalarList. Pull Request resolved: pytorch#88157 Approved by: https://github.com/ngimel, https://github.com/albanD
Support passing value scalars as a flat 1D Tensor. Currently we can only pass either an individual scalar or a ScalarList. Pull Request resolved: pytorch#88157 Approved by: https://github.com/ngimel, https://github.com/albanD
Support passing value scalars as a flat 1D Tensor.
Currently we can only pass either an individual scalar or a ScalarList.