-
Notifications
You must be signed in to change notification settings - Fork 7.2k
allow size to be generic Sequence #7999
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
For example, when we pass a `size` arg in a config created by omegaconf, only allowing `list, tuple` will raise an error.
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 @wangg12 , LGTM (I'll self-commit my suggestion below and wait for the CI before merging)
Technically we should probably be using Sequence
from collections.abc
instead of from typing
(EDIT: because most of the typing
stuff is deprecated from 3.9), but maybe this is better addressed in a more general PR. @pmeier any opinion?
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.
Technically we should probably be using
Sequence
fromcollections.abc
instead of fromtyping
, but maybe this is better addressed in a more general PR.
typing.Sequence
is actually an alias for collections.abc.Sequence
. Meaning, we can do it for clarity, but there is no functional difference.
Should we also fix the error message below to reflect that this supports arbitrary sequences now?
vision/torchvision/transforms/v2/_geometry.py
Lines 140 to 143 in 1a9ff0d
else: | |
raise ValueError( | |
f"size can either be an integer or a list or tuple of one or two integers, " f"but got {size} instead." | |
) |
Linux unittests and linters are happy, merging. Thanks @wangg12 ! |
Reviewed By: vmoens Differential Revision: D50789091 fbshipit-source-id: e9d6cebe293c2c8052b2ae0f731b0a5888309829 Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Co-authored-by: Nicolas Hug <nh.nicolas.hug@gmail.com>
For example, when we pass a
size
arg in a config created by omegaconf, only allowinglist, tuple
will raise an error.cc @vfdev-5