-
Notifications
You must be signed in to change notification settings - Fork 4.7k
deepcompile: Create a full list of no-copy ops #7562
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
deepcompile: Create a full list of no-copy ops #7562
Conversation
|
Hi @eternalNight, |
Good point. I should have tested the logic on different PyTorch versions. I just tried Python 3.8.20 with PyTorch 2.0.0, and confirmed that all ops under torch.ops.aten have schema and the logic in this PR works as expected. So older PyTorch versions (not older than 2.0.0 since torch compile is not officially introduced then) should not be a problem. Speaking of future versions where the schema of some ops is missing, to be conservative we should assume that they MAY reuse tensor storage. I'll update the except case to include such ops as well as print a warning message on its potential performance impact. |
c96ddfc to
9db926e
Compare
|
Hi @eternalNight, |
Head branch was pushed to by a user without write access
9db926e to
21cee09
Compare
The list of torch no-copy ops is hard coded and does not include all operations that may aliasing inputs in their outputs. Instead of using a fixed list, iterate over all ops under torch.ops.aten and identify those with aliasing behavior by inspecting their schema. All ops under torch.ops.aten have a schema since PyTorch 2.0.0, but just in case, ops without a schema are conservatively assumed to have aliasing behavior and a warning will be printed in such cases. With PyTorch 2.7.1, the default overload of ops identified by the updated logic include: - _nested_view_from_buffer - _reshape_alias - alias - as_strided - conj - detach - diagonal - expand - imag - lift_fresh - narrow - permute - pin_memory - positive - real - reshape - squeeze - t - unfold - unsqueeze - view - view_as_complex - view_as_real - most operations whose name ends with an underscore Signed-off-by: Junjie Mao <[email protected]>
21cee09 to
de8a258
Compare
The list of torch no-copy ops is hard coded and does not include all operations that may aliasing inputs in their outputs. Instead of using a fixed list, iterate over all ops under torch.ops.aten and identify those with aliasing behavior by inspecting their schema. With PyTorch 2.7.1, the default overload of ops identified by the updated logic include: - _nested_view_from_buffer - _reshape_alias - alias - as_strided - conj - detach - diagonal - expand - imag - lift_fresh - narrow - permute - pin_memory - positive - real - reshape - squeeze - t - unfold - unsqueeze - view - view_as_complex - view_as_real - most operations whose name ends with an underscore Signed-off-by: Junjie Mao <[email protected]>
The list of torch no-copy ops is hard coded and does not include all operations that may aliasing inputs in their outputs.
Instead of using a fixed list, iterate over all ops under torch.ops.aten and identify those with aliasing behavior by inspecting their schema.
With PyTorch 2.7.1, the default overload of ops identified by the updated logic include: