pytorch
99003101 - Fix sign warnings in CUDA kernels (#66753)

Commit
3 years ago
Fix sign warnings in CUDA kernels (#66753) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/66753 Fixes these Wextra compilation errors: ``` stderr: caffe2/aten/src/ATen/native/cuda/UnarySignKernels.cu: In lambda function: caffe2/aten/src/ATen/native/cuda/UnarySignKernels.cu:49:72: error: comparison is always false due to limited range of data type [-Werror=type-limits] 49 | AT_DISPATCH_ALL_TYPES_AND2 (https://github.com/pytorch/pytorch/commit/44fd312604fff5244e6d4fa1b3e440dd9b9e959f)(kBFloat16, ScalarType::Half, iter.input_dtype(), "signbit_cuda", [&]() { | ~~^~~ stderr: caffe2/aten/src/ATen/native/cuda/BinaryMulDivKernel.cu: In lambda function: caffe2/aten/src/ATen/native/cuda/BinaryMulDivKernel.cu:99:86: error: comparison is always false due to limited range of data type [-Werror=type-limits] 99 | AT_DISPATCH_INTEGRAL_TYPES(dtype, "div_floor_cuda", [&]() { | ^ caffe2/aten/src/ATen/native/cuda/BinaryMulDivKernel.cu:99:97: error: comparison is always false due to limited range of data type [-Werror=type-limits] 99 | AT_DISPATCH_INTEGRAL_TYPES(dtype, "div_floor_cuda", [&]() { | ^ stderr: caffe2/aten/src/ATen/native/cuda/BinaryMulDivKernel.cu: In lambda function: caffe2/aten/src/ATen/native/cuda/BinaryMulDivKernel.cu:99:86: error: comparison is always false due to limited range of data type [-Werror=type-limits] 99 | AT_DISPATCH_INTEGRAL_TYPES(dtype, "div_floor_cuda", [&]() { | ^ ``` And also these warnings: ``` caffe2/c10/util/Half.h(461): warning: pointless comparison of unsigned integer with zero detected during instantiation of "std::enable_if<<expression>, __nv_bool>::type c10::overflows<To,From>(From) [with To=size_t, From=unsigned long]" caffe2/aten/src/ATen/native/Resize.h(45): here caffe2/c10/util/Half.h(459): warning: pointless comparison of unsigned integer with zero detected during instantiation of "std::enable_if<<expression>, __nv_bool>::type c10::overflows<To,From>(From) [with To=size_t, From=unsigned long]" caffe2/aten/src/ATen/native/Resize.h(45): here ``` I thought I'd fixed this previously using `std::is_unsigned` in D25256251 (https://github.com/pytorch/pytorch/commit/cff1ff7fb6744dd6370ccccc5c90230ca3721140), but apparently that was insufficient. Test Plan: Sandcastle Reviewed By: malfet, ngimel Differential Revision: D31708173 fbshipit-source-id: 7714f6bbf109d2f2164630d3fc46bad18046c06c
Author
Parents
Loading