From 09d5729b6fc62688f9a10cc204d40b49c4a67662 Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:21:15 -0700 Subject: [PATCH 1/5] [BE] Fix compilation on CentOS-7 with devtoolset-9 As isinf on this platform is not really standard compliant (i.e. it's `int isinf(long double)` ) --- kernels/portable/cpu/op_isinf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernels/portable/cpu/op_isinf.cpp b/kernels/portable/cpu/op_isinf.cpp index da8599d5fac..8f67cc830cf 100644 --- a/kernels/portable/cpu/op_isinf.cpp +++ b/kernels/portable/cpu/op_isinf.cpp @@ -14,8 +14,13 @@ namespace torch { namespace executor { namespace native { +namespace { +bool isinf(double x) { + return ::std::isinf(x); +} +} 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, ctx, in, out); } } // namespace native From d40650456fc6012391cef2ba90644c1449b9fa0b Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:28:57 -0700 Subject: [PATCH 2/5] Update op_isinf.cpp --- kernels/portable/cpu/op_isinf.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/kernels/portable/cpu/op_isinf.cpp b/kernels/portable/cpu/op_isinf.cpp index 8f67cc830cf..f4648d303bf 100644 --- a/kernels/portable/cpu/op_isinf.cpp +++ b/kernels/portable/cpu/op_isinf.cpp @@ -14,13 +14,8 @@ namespace torch { namespace executor { namespace native { -namespace { -bool isinf(double x) { - return ::std::isinf(x); -} -} Tensor& isinf_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool(isinf, ctx, in, out); + return internal::unary_ufunc_realhb_to_bool([](double x) {return std::isinf(x); }, ctx, in, out); } } // namespace native From dc193a0eea3b2e92958236b297589b761c5006d6 Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:33:40 -0700 Subject: [PATCH 3/5] Update op_isnan.cpp --- kernels/portable/cpu/op_isnan.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernels/portable/cpu/op_isnan.cpp b/kernels/portable/cpu/op_isnan.cpp index 2a82b127d3e..5117e3db2c6 100644 --- a/kernels/portable/cpu/op_isnan.cpp +++ b/kernels/portable/cpu/op_isnan.cpp @@ -15,7 +15,7 @@ namespace executor { namespace native { 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([](double x) { return ::std::isnan(x); }, ctx, in, out); } } // namespace native From bd8de1b2e4d5c9ba89fa911d7e26ac9e3da2b95d Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 23 Apr 2024 17:45:50 -0700 Subject: [PATCH 4/5] Apply suggestions from code review --- kernels/portable/cpu/op_isinf.cpp | 2 +- kernels/portable/cpu/op_isnan.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernels/portable/cpu/op_isinf.cpp b/kernels/portable/cpu/op_isinf.cpp index f4648d303bf..cfcfd10a1f9 100644 --- a/kernels/portable/cpu/op_isinf.cpp +++ b/kernels/portable/cpu/op_isinf.cpp @@ -15,7 +15,7 @@ namespace executor { namespace native { Tensor& isinf_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool([](double x) {return std::isinf(x); }, ctx, in, out); + return internal::unary_ufunc_realhb_to_bool(static_cast(std::isinf), ctx, in, out); } } // namespace native diff --git a/kernels/portable/cpu/op_isnan.cpp b/kernels/portable/cpu/op_isnan.cpp index 5117e3db2c6..3803959589a 100644 --- a/kernels/portable/cpu/op_isnan.cpp +++ b/kernels/portable/cpu/op_isnan.cpp @@ -15,7 +15,7 @@ namespace executor { namespace native { Tensor& isnan_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool([](double x) { return ::std::isnan(x); }, ctx, in, out); + return internal::unary_ufunc_realhb_to_bool(static_cast(std::isnan), ctx, in, out); } } // namespace native From a12d452bed6a82daa978d6fb488d4e6c402369d1 Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:06:48 +0000 Subject: [PATCH 5/5] Fix lint --- kernels/portable/cpu/op_isinf.cpp | 3 ++- kernels/portable/cpu/op_isnan.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernels/portable/cpu/op_isinf.cpp b/kernels/portable/cpu/op_isinf.cpp index cfcfd10a1f9..49db65dfcc8 100644 --- a/kernels/portable/cpu/op_isinf.cpp +++ b/kernels/portable/cpu/op_isinf.cpp @@ -15,7 +15,8 @@ namespace executor { namespace native { Tensor& isinf_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool(static_cast(std::isinf), ctx, in, out); + return internal::unary_ufunc_realhb_to_bool( + static_cast(std::isinf), ctx, in, out); } } // namespace native diff --git a/kernels/portable/cpu/op_isnan.cpp b/kernels/portable/cpu/op_isnan.cpp index 3803959589a..52857990904 100644 --- a/kernels/portable/cpu/op_isnan.cpp +++ b/kernels/portable/cpu/op_isnan.cpp @@ -15,7 +15,8 @@ namespace executor { namespace native { Tensor& isnan_out(RuntimeContext& ctx, const Tensor& in, Tensor& out) { - return internal::unary_ufunc_realhb_to_bool(static_cast(std::isnan), ctx, in, out); + return internal::unary_ufunc_realhb_to_bool( + static_cast(std::isnan), ctx, in, out); } } // namespace native