-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Recoded _max_value method using a dictionary #5566
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
💊 CI failures summary and remediationsAs of commit 93a7905 (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.
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! One last nit for your consideration:
We could probably also add an xfail test like import torch
import pytest
@pytest.mark.xfail(
reason="torch.iinfo() is not supported by torchscript. See https://github.com/pytorch/pytorch/issues/41492."
)
def test_max_value_iinfo():
@torch.jit.script
def max_value(image: torch.Tensor) -> int:
return 1 if image.is_floating_point() else torch.iinfo(image.dtype).max to nudge us to switch as soon as support is added. |
elif dtype == torch.int64: | ||
return int(2 ** 63) - 1 | ||
else: | ||
return 1 |
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.
JIT on internal tests REALLY doesn't like this and fails with:
runtime error: 9.22337e+18 is outside the range of representable values of type 'long'
Replacing this with the following works:
def _max_value(dtype: torch.dtype) -> int:
if dtype == torch.uint8:
return 255
elif dtype == torch.int8:
return 127
elif dtype == torch.int16:
return 32767
elif dtype == torch.int32:
return 2147483647
elif dtype == torch.int64:
return 9223372036854775807
else:
return 1
I'll cherrypick it after it's merged internally.
Summary: * Removed _max_value method and added a dictionary Related to #5502 * Addressed failing tests and restored _max_value method * Added xfailing test to switch quicker * Switch to if/else impl Reviewed By: vmoens Differential Revision: D34878986 fbshipit-source-id: 2e8268eda1bff6f5375fc1b1c946a68af539689b
Description:
Related to #5502
cc @datumbox