From 7da3a7480709c828171d84cb9f11923df9beb129 Mon Sep 17 00:00:00 2001 From: qili93 Date: Tue, 28 May 2024 10:33:41 +0800 Subject: [PATCH] fix windows openblas ci fail --- paddle/phi/kernels/cpu/histogram_kernel.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/paddle/phi/kernels/cpu/histogram_kernel.cc b/paddle/phi/kernels/cpu/histogram_kernel.cc index 030dee9908b31c..eba05f4b0810a2 100644 --- a/paddle/phi/kernels/cpu/histogram_kernel.cc +++ b/paddle/phi/kernels/cpu/histogram_kernel.cc @@ -51,6 +51,21 @@ void HistogramKernel(const Context& dev_ctx, output_max = output_max + 1; } + // check if out of range + double range = + static_cast(output_max) - static_cast(output_min); + PADDLE_ENFORCE_LT( + range, + static_cast(std::numeric_limits::max()), + phi::errors::InvalidArgument( + "The range of max - min is out of range for target type, " + "current kernel type is %s, the range should less than %f " + "but now min is %f, max is %f.", + typeid(T).name(), + std::numeric_limits::max(), + output_min, + output_max)); + PADDLE_ENFORCE_EQ((std::isinf(static_cast(output_min)) || std::isnan(static_cast(output_max)) || std::isinf(static_cast(output_min)) ||