Skip to content

remove _is_foreach_op codegen special cases, clean up mutable return type checks#76190

Closed
bdhirsh wants to merge 6 commits intogh/bdhirsh/216/basefrom
gh/bdhirsh/216/head
Closed

remove _is_foreach_op codegen special cases, clean up mutable return type checks#76190
bdhirsh wants to merge 6 commits intogh/bdhirsh/216/basefrom
gh/bdhirsh/216/head

Conversation

@bdhirsh
Copy link
Collaborator

@bdhirsh bdhirsh commented Apr 21, 2022

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in #76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a Tensor? or a Tensor[]), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.

Stack from ghstack:

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 21, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 12f91b3 (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.

Click here to manually regenerate this comment.

…ble return type checks"

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in 76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a `Tensor?` or a `Tensor[]`), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.





[ghstack-poisoned]
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so speedy, thanks a lot!

bdhirsh added 3 commits April 22, 2022 05:45
…ble return type checks"

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in 76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a `Tensor?` or a `Tensor[]`), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.





[ghstack-poisoned]
…ble return type checks"

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in 76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a `Tensor?` or a `Tensor[]`), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.





[ghstack-poisoned]
…ble return type checks"

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in #76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a `Tensor?` or a `Tensor[]`), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.





[ghstack-poisoned]
…ble return type checks"

This PR cleans up some of the codegen type checks / special casing for foreach ops.

In particular, as described in #76049, schemas that mutate their inputs and return the mutated input directly as an output are only really useful for method chaining. If your schema involves a mutable input that you can't easily method chain on (like a `Tensor?` or a `Tensor[]`), then we expect the return type to be void.

We actually also have to allow return types of tuples of mutable tensors, since we have a bunch of ops that fit that description today.





[ghstack-poisoned]
@bdhirsh
Copy link
Collaborator Author

bdhirsh commented Apr 25, 2022

@pytorchbot merge this please

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Command git -C /home/runner/work/pytorch/pytorch cherry-pick -x b36afa294f5b0e0c49b910a67f39a4ed6027cc74 returned non-zero exit code 1
Auto-merging aten/src/ATen/native/Fill.cpp
Auto-merging aten/src/ATen/native/native_functions.yaml
Auto-merging test/test_functionalization.py
CONFLICT (content): Merge conflict in test/test_functionalization.py
Auto-merging tools/autograd/derivatives.yaml
Auto-merging tools/autograd/gen_python_functions.py
CONFLICT (content): Merge conflict in tools/autograd/gen_python_functions.py
error: could not apply b36afa2... functionalization: add native fill() op
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".

Raised by https://github.com/pytorch/pytorch/actions/runs/2223000776

@bdhirsh bdhirsh reopened this Apr 25, 2022
@bdhirsh bdhirsh closed this Apr 25, 2022
facebook-github-bot pushed a commit that referenced this pull request Apr 26, 2022
…type checks (#76190)

Summary:
Pull Request resolved: #76190

Approved by: https://github.com/ezyang

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/74e93f727a732c9a5208c75eca0f9551399372fd

Reviewed By: osalpekar

Differential Revision: D35938193

Pulled By: bdhirsh

fbshipit-source-id: 5a57ac39891f0f74184d7420189a9b09125d9a7f
@facebook-github-bot facebook-github-bot deleted the gh/bdhirsh/216/head branch April 29, 2022 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants