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
functionalization: add a copy() native function #76083
Conversation
[ghstack-poisoned]
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 34893d8 (more details on the Dr. CI page): Expand to see more
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakagespull / linux-bionic-py3.7-clang9 / test (default, 1, 2, linux.2xlarge) (1/1)Step: "Test" (full log | diagnosis details | 🔁 rerun)
|
[ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
Right now the functionalization codegen has special logic to handle `copy_()`. Instead, in this PR I add an `at::copy` native function (not exposed to python), and effectively move that logic into C++ and out of the codegen. `copy()` decomposes into `to` and `expand`, and it's CompositeImplicitAutograd so it won't appear in traces. One annoying thing - since `copy()` decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly because `at::copy()` really just exists for the functionalization pass anyway. Existing tests for `copy_` in `test_functionalization.py` should test the change (since the end-result trace is the same). [ghstack-poisoned]
@pytorchbot merge this please |
Hey @bdhirsh. |
Summary: Pull Request resolved: #76083 Approved by: https://github.com/albanD Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/5da76acd1d8ad1c40f8d58d52a12aa215dbae7ce Reviewed By: osalpekar Differential Revision: D35938186 Pulled By: bdhirsh fbshipit-source-id: 4a93d39088b5944cf4911c9c08feb549ecb72ac3
Right now the functionalization codegen has special logic to handle
copy_()
. Instead, in this PR I add anat::copy
native function (not exposed to python), and effectively move that logic into C++ and out of the codegen.copy()
decomposes intoto
andexpand
, and it's CompositeImplicitAutograd so it won't appear in traces.One annoying thing - since
copy()
decomposes into a view op, and it decomposes "underneath" functionalization, I need to manually handle the case where we want to remove view ops from the functionalization pass. This feels not-too-awful mostly becauseat::copy()
really just exists for the functionalization pass anyway.Existing tests for
copy_
intest_functionalization.py
should test the change (since the end-result trace is the same).Stack from ghstack: