pytorch
dc7d3fd4 - functionalization: fix _unsafe_view debug asserts (#80526)

Commit
2 years ago
functionalization: fix _unsafe_view debug asserts (#80526) Fixes `_unsafe_view` for functionalization - previously, autograd debug-asserts were failing in `test/test_functionalization.py`, but this should fix them (PS: looking forward to when we run a debug-build test in our CI infra) In a previous PR, I tried to fix `_unsafe_view` by "fixing" its alias annotations in native_functions.yaml to reflect the fact that it's a view, and adding new operators for `_unsafe_view_copy` and `_unsafe_view_copy.out` That broke some torchscript tests. It also feels too heavy-weight, since the whole point of `_unsafe_view` is that we shouldn't actually have to worry about treating it like a real view: we don't need to worry about having to propagate mutations between the input and the output, because the input is meant to be a temporary tensor that gets thrown away. So instead, I just wrote a one-off kernel for `_unsafe_view` for functionalization - it does the same thing as the old (boxed fallback) kernel would do, but also correctly aliases the storages together, to appease autograd asserts. Pull Request resolved: https://github.com/pytorch/pytorch/pull/80526 Approved by: https://github.com/ezyang
Author
Committer
Parents
Loading