-
Notifications
You must be signed in to change notification settings - Fork 7k
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
simplify Feature implementation #5539
Conversation
💊 CI failures summary and remediationsAs of commit ef2efb1 (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. |
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.
Apart from two previously undetected typing errors that were surfaced by this patch, all changes only happen in the prototype.features
module. Given that all tests are passing and mypy
is also happy, I'm guessing that this change is indeed functional equivalent.
cls._to_tensor(data, dtype=dtype, device=device), | ||
# requires_grad | ||
False, | ||
torch.as_tensor(data, dtype=dtype, device=device), # type: ignore[arg-type] |
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.
As discussed offline, the annotations of as_tensor
are wrong. str
and int
are valid types for the device
.
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.
Thanks @pmeier , LGTM. Would you mind adding a description to the PR, something like (feel free to edit)
This removes the
__init_subclass__()
and_to_tensor()
methods of_Feature
.__init_subclass__()
was inspecting the mro and dynamically setting attribute of class instances through the_META_ATTRS
and_metadata
attributes which are now removed. Instead, we now addnew_like()
class method to all _Feature subclasses: slightly more verbose, but much simpler.
Hey @pmeier! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
Summary: * simplify Feature implementation * fix mypy Reviewed By: vmoens Differential Revision: D34878978 fbshipit-source-id: 765518672e48d53d1f61e5d71c3f7dddc902948c
This removes the
__init_subclass__()
and_to_tensor()
methods of_Feature
.__init_subclass__()
was inspecting the MRO and dynamically setting attribute of class instances through the_META_ATTRS
and_metadata
attributes which are now removed. Instead, we now addnew_like()
class method to all _Feature subclasses: slightly more verbose, but much simpler.