diff --git a/kernels/portable/cpu/op_isinf.cpp b/kernels/portable/cpu/op_isinf.cpp index da8599d5fa..0ac1fa1195 100644 --- a/kernels/portable/cpu/op_isinf.cpp +++ b/kernels/portable/cpu/op_isinf.cpp @@ -14,8 +14,18 @@ namespace torch { namespace executor { namespace native { +namespace { +// Passing std::isinf directly to unary_ufunc_realhb_to_bool can cause "error: +// cannot resolve overloaded function ‘isinf’ based on conversion to type +// ‘torch::executor::FunctionRef’" in some compilation +// environments. +bool isinf_wrapper(double num) { + return std::isinf(num); +} +} // namespace + Tensor& isinf_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool(std::isinf, ctx, in, out); + return internal::unary_ufunc_realhb_to_bool(isinf_wrapper, ctx, in, out); } } // namespace native diff --git a/kernels/portable/cpu/op_isnan.cpp b/kernels/portable/cpu/op_isnan.cpp index 2a82b127d3..d9ef038b73 100644 --- a/kernels/portable/cpu/op_isnan.cpp +++ b/kernels/portable/cpu/op_isnan.cpp @@ -14,8 +14,18 @@ namespace torch { namespace executor { namespace native { +namespace { +// Passing std::isnan directly to unary_ufunc_realhb_to_bool can cause "error: +// cannot resolve overloaded function ‘isnan’ based on conversion to type +// ‘torch::executor::FunctionRef’" in some compilation +// environments. +bool isnan_wrapper(double num) { + return std::isnan(num); +} +} // namespace + Tensor& isnan_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool(std::isnan, ctx, in, out); + return internal::unary_ufunc_realhb_to_bool(isnan_wrapper, ctx, in, out); } } // namespace native