From 40a245f943330219e59adaf9c0d23139d674a5b5 Mon Sep 17 00:00:00 2001 From: SiCongLi Date: Thu, 2 Dec 2021 11:54:32 +0000 Subject: Unify Cpu Max pool 2d minimum value to be -inf for floating point Resolves: COMPMID-4998 Signed-off-by: SiCongLi Change-Id: Ia34c4b063ebcdb193db0a3d6c22f6769a8a902d5 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6822 Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- src/cpu/kernels/pool2d/neon/nchw/all.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/cpu/kernels/pool2d/neon/nchw/all.cpp') diff --git a/src/cpu/kernels/pool2d/neon/nchw/all.cpp b/src/cpu/kernels/pool2d/neon/nchw/all.cpp index 109fc1b283..ec18f40569 100644 --- a/src/cpu/kernels/pool2d/neon/nchw/all.cpp +++ b/src/cpu/kernels/pool2d/neon/nchw/all.cpp @@ -421,7 +421,7 @@ void poolingMxN_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, const int src_h = src->info()->dimension(1); const int upper_bound_w = src_w + (pool_info.exclude_padding ? 0 : pool_pad_right); const int upper_bound_h = src_h + (pool_info.exclude_padding ? 0 : pool_pad_bottom); - const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::max() : 0.0f; + const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::infinity() : 0.0f; execute_window_loop(window, [&](const Coordinates & id) { @@ -459,7 +459,7 @@ void poolingMxN_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, } else // if max pooling { - res = std::numeric_limits::lowest(); + res = -std::numeric_limits::infinity(); for(int y = 0; y < pool_size_y; ++y) { @@ -510,7 +510,7 @@ void pooling2_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, P const int src_h = src->info()->dimension(1); const int upper_bound_w = src_w + (pool_info.exclude_padding ? 0 : pool_pad_right); const int upper_bound_h = src_h + (pool_info.exclude_padding ? 0 : pool_pad_bottom); - const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::max() : 0.0f; + const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::infinity() : 0.0f; const uint8_t *const src_top_ptr = src->ptr_to_element(Coordinates(-static_cast(pool_pad_left), -static_cast(pool_pad_top))); const uint8_t *const src_bottom_ptr = src->ptr_to_element(Coordinates(-static_cast(pool_pad_left), -static_cast(pool_pad_top) + 1)); @@ -584,7 +584,7 @@ void pooling3_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, P const int src_h = src->info()->dimension(1); const int upper_bound_w = src_w + (pool_info.exclude_padding ? 0 : pool_pad_right); const int upper_bound_h = src_h + (pool_info.exclude_padding ? 0 : pool_pad_bottom); - const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::max() : 0.0f; + const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::infinity() : 0.0f; const uint8_t *const src_top_ptr = src->ptr_to_element(Coordinates(-static_cast(pool_pad_left), -static_cast(pool_pad_top))); const uint8_t *const src_middle_ptr = src->ptr_to_element(Coordinates(-static_cast(pool_pad_left), -static_cast(pool_pad_top) + 1)); @@ -630,7 +630,7 @@ void pooling3_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, P else { const float32x4_t max_data = vmaxq_f32(vmaxq_f32(top_data, bottom_data), middle_data); - res = vpmax_f32(vget_high_f32(vsetq_lane_f32(-std::numeric_limits::max(), max_data, 3)), vget_low_f32(max_data)); + res = vpmax_f32(vget_high_f32(vsetq_lane_f32(-std::numeric_limits::infinity(), max_data, 3)), vget_low_f32(max_data)); res = vpmax_f32(res, res); } final_res = vget_lane_f32(res, 0); @@ -665,7 +665,7 @@ void pooling7_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, P const int src_h = src->info()->dimension(1); const int upper_bound_w = src_w + (pool_info.exclude_padding ? 0 : pool_pad_right); const int upper_bound_h = src_h + (pool_info.exclude_padding ? 0 : pool_pad_bottom); - const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::max() : 0.0f; + const float fill_value = (pool_info.pool_type == PoolingType::MAX) ? -std::numeric_limits::infinity() : 0.0f; std::array src_ptrs{ {} }; for(int i = 0; i < pool_size; ++i) @@ -728,7 +728,7 @@ void pooling7_fp32_neon_nchw(const ITensor *src, ITensor *dst0, ITensor *dst1, P float32x4x2_t temp = read_8_boundary_aware(src_h, src_w, pool_pad_left, pool_pad_top, x_val, y_val, in_ptr, fill_value); data = vmax2q_f32(data, temp); } - res = vpmax_f32(vget_high_f32(vsetq_lane_f32(-std::numeric_limits::max(), data.val[1], 3)), vget_low_f32(data.val[1])); + res = vpmax_f32(vget_high_f32(vsetq_lane_f32(-std::numeric_limits::infinity(), data.val[1], 3)), vget_low_f32(data.val[1])); res = vpmax_f32(res, vpmax_f32(vget_high_f32(data.val[0]), vget_low_f32(data.val[0]))); res = vpmax_f32(res, res); } -- cgit v1.2.1