Skip to content

Conversation

@zou3519
Copy link
Contributor

@zou3519 zou3519 commented Apr 15, 2022

All of the torch.return_types.* are these special things "structseq"
that subclass tuple but have a different constructor from tuple :(.

This PR iterates through all of torch.return_types.* and adds a pytree
registration for them.

Test Plan:

  • add tests for max and min which return torch.return_types.max, and
    torch.return_types.min, respectively. There's not an easy way to
    "get all torch ops that return a return_types object".

Fixes #75218

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Apr 15, 2022

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 4b8657a (more details on the Dr. CI page):


💚 💚 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.

@zou3519 zou3519 force-pushed the tree_map_return_types branch from 518ffd6 to 037dc1e Compare April 15, 2022 21:13
@zou3519 zou3519 requested review from Chillee and ezyang April 18, 2022 14:05
_register_pytree_node(tuple, _tuple_flatten, _tuple_unflatten)
_register_pytree_node(namedtuple, _namedtuple_flatten, _namedtuple_unflatten)


Copy link
Contributor

Choose a reason for hiding this comment

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

kill this fuzz

@ezyang ezyang requested a review from kshitij12345 April 18, 2022 17:04
@ezyang
Copy link
Contributor

ezyang commented Apr 18, 2022

I would like to know if there's a more proper way to check structseq but I wouldn't block this on it

All of the torch.return_types.* are these special things "structseq"
that subclass tuple but have a different constructor from tuple :(.

This PR iterates through all of torch.return_types.* and adds a pytree
registration for them.

Test Plan:
- add tests for max and min which return torch.return_types.max, and
torch.return_types.min, respectively. There's not an easy way to
"get all torch ops that return a return_types object".
@zou3519 zou3519 force-pushed the tree_map_return_types branch from 037dc1e to 4b8657a Compare April 18, 2022 17:22
@zou3519
Copy link
Contributor Author

zou3519 commented Apr 18, 2022

I would like to know if there's a more proper way to check structseq but I wouldn't block this on it

I'll file a followup issue

@zou3519
Copy link
Contributor Author

zou3519 commented Apr 19, 2022

@pytorchbot merge this please

@github-actions
Copy link
Contributor

Hey @zou3519.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Apr 19, 2022
Summary:
All of the torch.return_types.* are these special things "structseq"
that subclass tuple but have a different constructor from tuple :(.

This PR iterates through all of torch.return_types.* and adds a pytree
registration for them.

Pull Request resolved: #75915
Approved by: https://github.com/ezyang, https://github.com/kshitij12345

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

Test plan from GitHub:
- add tests for max and min which return torch.return_types.max, and
torch.return_types.min, respectively. There's not an easy way to
"get all torch ops that return a return_types object".

Fixes #75218

Reviewed By: seemethere

Differential Revision: D35751456

Pulled By: zou3519

fbshipit-source-id: 88a5289019eb4f5642f8e9ece6791581a0f2b7a9
malfet pushed a commit that referenced this pull request Apr 20, 2022
All of the torch.return_types.* are these special things "structseq"
that subclass tuple but have a different constructor from tuple :(.

This PR iterates through all of torch.return_types.* and adds a pytree
registration for them.

Test Plan:
- add tests for max and min which return torch.return_types.max, and
torch.return_types.min, respectively. There's not an easy way to
"get all torch ops that return a return_types object".

Fixes #75218

Pull Request resolved: #75915
Approved by: https://github.com/ezyang, https://github.com/kshitij12345

(cherry picked from commit 18c74d1)
@github-actions github-actions bot deleted the tree_map_return_types branch February 15, 2024 01:59
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.

tree_map doesn't work over return_types

5 participants