-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Enforce that named_tensor_meta_ is non-null only if there is a non-wildcard name #38725
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
Conversation
…ldcard name Today, there are two equivalent representations: named_tensor_meta_ is null, or named_tensor_meta_ is non-null but all of the dimension names are wildcard. Let's reduce the opportunity for behavior divergence by making the second representation illegal. This will make it easier for me to add a dispatch key for named tensor as I can rely on setters to always go through TensorImpl to maintain invariants on DispatchKey. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
…ldcard name Today, there are two equivalent representations: named_tensor_meta_ is null, or named_tensor_meta_ is non-null but all of the dimension names are wildcard. Let's reduce the opportunity for behavior divergence by making the second representation illegal. This will make it easier for me to add a dispatch key for named tensor as I can rely on setters to always go through TensorImpl to maintain invariants on DispatchKey. Signed-off-by: Edward Z. Yang <ezyang@fb.com> ghstack-source-id: 621506e Pull Request resolved: #38725
💊 CI failures summary and remediationsAs of commit 8970b88 (more details on the Dr. CI page):
ci.pytorch.org: 1 failedThis comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 12 times. |
…is a non-wildcard name" Today, there are two equivalent representations: named_tensor_meta_ is null, or named_tensor_meta_ is non-null but all of the dimension names are wildcard. Let's reduce the opportunity for behavior divergence by making the second representation illegal. This will make it easier for me to add a dispatch key for named tensor as I can rely on setters to always go through TensorImpl to maintain invariants on DispatchKey. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
aten/src/ATen/core/NamedTensor.h
Outdated
// non-wildcard | ||
struct CAFFE2_API NamedTensorMeta final : public c10::NamedTensorMetaInterface { | ||
// This enum is to remind people that the invariant on constructors is that | ||
// the list of dimnames must have at least one non-wilddcard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: wilddcard -> wildcard
aten/src/ATen/core/NamedTensor.h
Outdated
|
||
void set_names(DimnameList new_names) { | ||
void check_invariants() const { | ||
// TORCH_INTERNAL_ASSERT_DEBUG_ONLY( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe delete this comment?
…is a non-wildcard name" Today, there are two equivalent representations: named_tensor_meta_ is null, or named_tensor_meta_ is non-null but all of the dimension names are wildcard. Let's reduce the opportunity for behavior divergence by making the second representation illegal. This will make it easier for me to add a dispatch key for named tensor as I can rely on setters to always go through TensorImpl to maintain invariants on DispatchKey. Signed-off-by: Edward Z. Yang <ezyang@fb.com> [ghstack-poisoned]
Stack from ghstack:
Today, there are two equivalent representations: named_tensor_meta_ is
null, or named_tensor_meta_ is non-null but all of the dimension names
are wildcard. Let's reduce the opportunity for behavior divergence by
making the second representation illegal.
This will make it easier for me to add a dispatch key for named
tensor as I can rely on setters to always go through TensorImpl to
maintain invariants on DispatchKey.
Signed-off-by: Edward Z. Yang ezyang@fb.com
Differential Revision: D21662641