From b09bfc86110ffe75dad52b7d6f01d6f2ade873d6 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Tue, 9 Feb 2021 21:27:36 -0800 Subject: [PATCH] Revert "Remove abs in LpPool (#6303)" This reverts commit 3b3e698674dca2014b91fb617e2c4f22ffd0c5c9. --- onnxruntime/core/providers/cpu/nn/pool_base.h | 2 +- .../test/providers/cpu/nn/pool_op_test.cc | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/onnxruntime/core/providers/cpu/nn/pool_base.h b/onnxruntime/core/providers/cpu/nn/pool_base.h index f4d0082866..3d1edfbdaf 100644 --- a/onnxruntime/core/providers/cpu/nn/pool_base.h +++ b/onnxruntime/core/providers/cpu/nn/pool_base.h @@ -88,7 +88,7 @@ class LpPool { template static void Process(const T& x_data, T& y_data, const PoolProcessContext& cxt) { - y_data += static_cast(std::pow(x_data, cxt.p_)); + y_data += static_cast(std::pow(std::abs(x_data), cxt.p_)); } template diff --git a/onnxruntime/test/providers/cpu/nn/pool_op_test.cc b/onnxruntime/test/providers/cpu/nn/pool_op_test.cc index f84da5cf9a..b9db7ad47f 100644 --- a/onnxruntime/test/providers/cpu/nn/pool_op_test.cc +++ b/onnxruntime/test/providers/cpu/nn/pool_op_test.cc @@ -1264,25 +1264,6 @@ TEST(PoolTest, LpPool) { test.Run(); } -TEST(PoolTest, LpPoolWithNegativeNumbers) { - OpTester test("LpPool"); - - test.AddAttribute("p", static_cast(1)); - test.AddAttribute("auto_pad", ""); - test.AddAttribute("strides", std::vector{2}); - test.AddAttribute("pads", vector{0, 0}); - test.AddAttribute("kernel_shape", vector{2}); - - std::vector x_vals = {0.2f, -0.6f}; - std::vector x_dims = {1, 1, 2}; - std::vector expected_dims = {1, 1, 1}; - std::vector expected_vals = {-0.4f}; - - test.AddInput("X", x_dims, x_vals); - test.AddOutput("Y", expected_dims, expected_vals); - test.Run(); -} - TEST(PoolTest, GlobalLpPool) { OpTester test("GlobalLpPool"); test.AddAttribute("p", static_cast(3));