-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Remove unneeded manual unwrap optionals #16245
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
raise ValueError("fractional_max_pool2d requires specifying either " | ||
"an output_size or an output_ratio") | ||
if output_size is None: | ||
_output_ratio = _pair(torch.jit._unwrap_optional(output_ratio)) |
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.
missing one
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.
This function throws an error if both output_size is None and output_ratio is None.
Then it checks if output_size is None, which therefore means output_ratio is not none. Since the NoneType inference doesn't do any reasoning like "either output_ratio or output_none is None" I included the manual unwrap. I could remove it by instead writing:
if output_size is None and output_ratio is not None:
raise ValueError("fractional_max_pool3d requires specifying either " | ||
"an output_size or an output_ratio") | ||
if output_size is None: | ||
_output_ratio = _triple(torch.jit._unwrap_optional(output_ratio)) |
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.
another
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.
Looks good to me if CI pass
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.
@eellison is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Remove calls to torch.jit._unwrap_optional that are no longer needed.
The remaining instances would require control flow logic for exceptions.