Prepare python jiterator for multiple outputs#77921
Prepare python jiterator for multiple outputs#77921SherlockNoMad wants to merge 1 commit intomasterfrom
Conversation
🔗 Helpful links
✅ No Failures (0 Pending)As of commit f4f09ac (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
4e0607a to
f4f09ac
Compare
ngimel
left a comment
There was a problem hiding this comment.
Looks good, if the tests pass
|
|
||
| template<int N> | ||
| static std::unique_ptr<OffsetCalculator<N>> make_unique_input_offset_calculator(const TensorIteratorBase& iter) { | ||
| template<bool IS_INPUT, int N> |
There was a problem hiding this comment.
doesn't look like IS_INPUT needs to be template arg?
There was a problem hiding this comment.
IIUC, compiler will try to optimize away the dead code path for such template arg.
so the switch is done at compilation time, rather than at run time.
|
@pytorchbot merge this |
|
Hey @SherlockNoMad. |
Summary: Part 2 for #77902 Further prepare python jiterator for supporting multiple outputs Pull Request resolved: #77921 Approved by: https://github.com/ngimel Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/c0abd834829ddaf015590dbd0c16b131e292cf36 Reviewed By: seemethere Differential Revision: D36603024 Pulled By: seemethere fbshipit-source-id: 190e409f0cb68d675da3b676a6fa658c0e32c107
This PR is part3. Part1: #77902 Part2: #77921 Python Jiterator now supports returning multiple outputs ``` fn = torch.cuda.jiterator._create_multi_output_jit_fn( """ template <typename T> T binary_2outputs(T i0, T i1, T& out0, T& out1) { out0 = i0 + i1; out1 = i0 - i1; } """, num_outputs=2) x = torch.rand(3, device='cuda') y = torch.rand(3, device='cuda') out0, out1 = fn(x, y) torch.allclose(out0, x+y) torch.allclose(out1, x-y) ``` Pull Request resolved: #78139 Approved by: https://github.com/ngimel
Part 2 for #77902 Further prepare python jiterator for supporting multiple outputs Pull Request resolved: #77921 Approved by: https://github.com/ngimel
Summary: This PR is part3. Part1: #77902 Part2: #77921 Python Jiterator now supports returning multiple outputs ``` fn = torch.cuda.jiterator._create_multi_output_jit_fn( """ template <typename T> T binary_2outputs(T i0, T i1, T& out0, T& out1) { out0 = i0 + i1; out1 = i0 - i1; } """, num_outputs=2) x = torch.rand(3, device='cuda') y = torch.rand(3, device='cuda') out0, out1 = fn(x, y) torch.allclose(out0, x+y) torch.allclose(out1, x-y) ``` Pull Request resolved: #78139 Approved by: https://github.com/ngimel Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/6db8440f35831a903a1084aec1a3803af0e1dd10 Reviewed By: mehtanirav Differential Revision: D36668751 Pulled By: SherlockNoMad fbshipit-source-id: 756ad6da1682030d6db8cad390a3a72ef3b44444
Part 2 for #77902
Further prepare python jiterator for supporting multiple outputs