Skip to content

Conversation

fmassa
Copy link
Member

@fmassa fmassa commented Dec 3, 2020

We could have errors with convert_image_dtype such as

aten/src/ATen/native/cpu/PowKernel.cpp:41:5:  runtime error: 5.7896e+76 is outside the range of representable values of type 'float'

This fixes it for now, while we can't use torch.iinfo and torch.finfo in torchscript

We could have errors such as aten/src/ATen/native/cpu/PowKernel.cpp:41:5:  runtime error: 5.7896e+76 is outside the range of representable values of type 'float'
image = image.to(dtype)
return image / input_max

output_max = _max_value(dtype)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear why moving this it fixes the errors. Shall I assume that the if statement is always activated in the problematic cases and thus you never end up executing this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the overflow only happens when dtype is floating point, so moving this after the conditional solves this

@fmassa fmassa merged commit dab4757 into pytorch:master Dec 3, 2020
@fmassa fmassa deleted the fix_convert_img_dtype_overflow branch December 3, 2020 18:40
vfdev-5 pushed a commit to Quansight/vision that referenced this pull request Dec 4, 2020
We could have errors such as aten/src/ATen/native/cpu/PowKernel.cpp:41:5:  runtime error: 5.7896e+76 is outside the range of representable values of type 'float'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants