Generalize sizes and strides policy on _make_wrapper_subclass#78646
Generalize sizes and strides policy on _make_wrapper_subclass#78646suo wants to merge 3 commits intogh/suo/533/basefrom
Conversation
Previously, there was a `dispatch_strides` boolean arg. Change this to a string argument that directly maps onto `SizesStridesPolicy`. [ghstack-poisoned]
🔗 Helpful links
✅ No Failures (0 Pending)As of commit 09a5e09 (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. |
…ass" Previously, there was a `dispatch_strides` boolean arg. Change this to a string argument that directly maps onto `SizesStridesPolicy`. [ghstack-poisoned]
albanD
left a comment
There was a problem hiding this comment.
Should we have at least one test for the size case?
| false, | ||
| "Unknown sizes_strides_policy: ", | ||
| arg, | ||
| "; expected 'strides' or 'sizes'"); |
There was a problem hiding this comment.
Is there some doc about what each values does?
There was a problem hiding this comment.
Right now sizes does not actually dispatch back into Python. Forthcoming PRs stacked on top will implement this and add tests.
Is there some doc about what each values does?
Ummmm, there's a big comment in tensorimpl
There was a problem hiding this comment.
But that's quite far from that python API :p
Also there is a small mismatch between what it changes for the TensorImpl and what ends up being called on __torch_dispatch__
There was a problem hiding this comment.
I can add documentation for it, where is are the docs for _make_wrapper_subclass/_make_subclass today?
As for the mismatch—I don't think that's fixable within the scope of this PR (and it already exists). But hopefully we'll finish coverage of the various tensorimpl methods soon and so at least we can document it?
There was a problem hiding this comment.
I don't think there is any code that needs changing. Just mentioning that because they work at very different levels the doc in TensorImpl might not be enough?
I can add documentation for it, where is are the docs for _make_wrapper_subclass/_make_subclass today?
For this, I think the TORCH_CHECK is a good place.
There was a problem hiding this comment.
hmmmm, I feel like it's weird to put the rules for what this argument does in the error message; we should probably just have like a real docstring?
Okay I'm going to merge this now, but I will take as a follow up:
- Finding the right place to describe the rules
- Making the code actually reflect the rules (e.g. make more things overridable from torchdispatch)
…ass" Previously, there was a `dispatch_strides` boolean arg. Change this to a string argument that directly maps onto `SizesStridesPolicy`. [ghstack-poisoned]
|
@pytorchbot help |
PyTorchBot HelpMergeRevertRebaseFor more info, consult the wiki." |
|
@pytorchbot merge -g |
|
Hey @suo. |
Summary: Previously, there was a `dispatch_strides` boolean arg. Change this to a string argument that directly maps onto `SizesStridesPolicy`. Pull Request resolved: #78646 Approved by: https://github.com/ezyang Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/876c359347faae9367cb390071034e8705bad90e Reviewed By: b0noI Differential Revision: D36854294 Pulled By: suo fbshipit-source-id: c535498d1c5ed88c6cdb40926fb49ced065907a5
Stack from ghstack:
Previously, there was a
dispatch_stridesboolean arg. Change this toa string argument that directly maps onto
SizesStridesPolicy.