#pragma once #ifdef __HIPCC__ #include #endif #include #include #include #include namespace at { // std::isnan isn't performant to use on integral types; it will // (uselessly) convert to floating point and then do the test. // This function is. template ::value, int>::type = 0> inline C10_HOST_DEVICE bool _isnan(T val) { return false; } template ::value, int>::type = 0> inline C10_HOST_DEVICE bool _isnan(T val) { #if defined(__CUDACC__) || defined(__HIPCC__) return ::isnan(val); #else return std::isnan(val); #endif } inline C10_HOST_DEVICE bool _isnan(at::BFloat16 val) { return at::_isnan(float(val)); } } // namespace at