aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-08-31 14:21:36 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:35:24 +0000
commitcdf51455df8835e9e3bfd3e31ed389146af9a573 (patch)
tree31b0bf9302decbf8b1063f46373e3d26a9ca1409 /tests
parent29088d517a2a9f249fe5cc851e0c97de3d4cc917 (diff)
downloadComputeLibrary-cdf51455df8835e9e3bfd3e31ed389146af9a573.tar.gz
COMPMID-515: L2 Pooling for FP32/FP16 in CL.
Change-Id: I43641fa672f5905ca62edd1f63fc93e0cf7ea382 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/85963 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/TypePrinter.h3
-rw-r--r--tests/datasets/PoolingTypesDataset.h2
-rw-r--r--tests/validation/CL/PoolingLayer.cpp2
-rw-r--r--tests/validation/CPP/PoolingLayer.cpp54
-rw-r--r--tests/validation/NEON/PoolingLayer.cpp2
5 files changed, 49 insertions, 14 deletions
diff --git a/tests/TypePrinter.h b/tests/TypePrinter.h
index 2f9909ca2e..d3d9f8f5ac 100644
--- a/tests/TypePrinter.h
+++ b/tests/TypePrinter.h
@@ -367,6 +367,9 @@ inline ::std::ostream &operator<<(::std::ostream &os, const PoolingType &pool_ty
case PoolingType::MAX:
os << "MAX";
break;
+ case PoolingType::L2:
+ os << "L2";
+ break;
default:
ARM_COMPUTE_ERROR("NOT_SUPPORTED!");
}
diff --git a/tests/datasets/PoolingTypesDataset.h b/tests/datasets/PoolingTypesDataset.h
index 5ba8aaf6d0..5994d6ecd0 100644
--- a/tests/datasets/PoolingTypesDataset.h
+++ b/tests/datasets/PoolingTypesDataset.h
@@ -41,7 +41,7 @@ public:
PoolingTypes()
: ContainerDataset("PoolType",
{
- PoolingType::MAX, PoolingType::AVG
+ PoolingType::MAX, PoolingType::AVG, PoolingType::L2
})
{
}
diff --git a/tests/validation/CL/PoolingLayer.cpp b/tests/validation/CL/PoolingLayer.cpp
index e82df07a91..44617f624c 100644
--- a/tests/validation/CL/PoolingLayer.cpp
+++ b/tests/validation/CL/PoolingLayer.cpp
@@ -48,7 +48,7 @@ const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), fra
framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
/** Input data set for quantized data types */
-const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })),
+const auto PoolingLayerDatasetQS = combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), framework::dataset::make("PoolingSize", { 2, 3 })),
framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */
diff --git a/tests/validation/CPP/PoolingLayer.cpp b/tests/validation/CPP/PoolingLayer.cpp
index f7273f073f..85a8343d87 100644
--- a/tests/validation/CPP/PoolingLayer.cpp
+++ b/tests/validation/CPP/PoolingLayer.cpp
@@ -104,7 +104,7 @@ SimpleTensor<T> pooling_layer(const SimpleTensor<T> &src, PoolingLayerInfo info)
}
}
}
- else // Average pooling
+ else // Average or l2 pooling
{
for(int r = 0; r < upper_dims; ++r)
{
@@ -123,14 +123,29 @@ SimpleTensor<T> pooling_layer(const SimpleTensor<T> &src, PoolingLayerInfo info)
wend = std::min(wend, w_src);
hend = std::min(hend, h_src);
- for(int y = hstart; y < hend; ++y)
+ if(type == PoolingType::AVG)
{
- for(int x = wstart; x < wend; ++x)
+ for(int y = hstart; y < hend; ++y)
+ {
+ for(int x = wstart; x < wend; ++x)
+ {
+ avg_val += src[r * h_src * w_src + y * w_src + x];
+ }
+ }
+ dst[r * h_dst * w_dst + h * w_dst + w] = avg_val / pool;
+ }
+ else
+ {
+ for(int y = hstart; y < hend; ++y)
{
- avg_val += src[r * h_src * w_src + y * w_src + x];
+ for(int x = wstart; x < wend; ++x)
+ {
+ const T val = src[r * h_src * w_src + y * w_src + x];
+ avg_val += val * val;
+ }
}
+ dst[r * h_dst * w_dst + h * w_dst + w] = std::sqrt(avg_val / pool);
}
- dst[r * h_dst * w_dst + h * w_dst + w] = avg_val / pool;
}
}
}
@@ -192,7 +207,7 @@ SimpleTensor<T> pooling_layer(const SimpleTensor<T> &src, PoolingLayerInfo info)
}
}
}
- else // Average pooling
+ else // Average or l2 pooling
{
for(int r = 0; r < upper_dims; ++r)
{
@@ -213,18 +228,35 @@ SimpleTensor<T> pooling_layer(const SimpleTensor<T> &src, PoolingLayerInfo info)
using namespace fixed_point_arithmetic;
const int fixed_point_position = src.fixed_point_position();
+ const fixed_point<T> const_1(1, fixed_point_position);
const fixed_point<T> invpool_fp(1.f / static_cast<float>(pool), fixed_point_position);
fixed_point<T> avg_val(0, fixed_point_position, true);
- for(int y = hstart; y < hend; ++y)
+ if(type == PoolingType::AVG)
{
- for(int x = wstart; x < wend; ++x)
+ for(int y = hstart; y < hend; ++y)
+ {
+ for(int x = wstart; x < wend; ++x)
+ {
+ const fixed_point<T> in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true);
+ avg_val = add(avg_val, in_fp);
+ }
+ }
+ dst[r * h_dst * w_dst + h * w_dst + w] = mul(avg_val, invpool_fp).raw();
+ }
+ else
+ {
+ for(int y = hstart; y < hend; ++y)
{
- const fixed_point<T> in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true);
- avg_val = add(avg_val, in_fp);
+ for(int x = wstart; x < wend; ++x)
+ {
+ const fixed_point<T> in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true);
+ avg_val = add(avg_val, mul(in_fp, in_fp));
+ }
}
+ auto res = div(const_1, (inv_sqrt(mul(avg_val, invpool_fp))));
+ dst[r * h_dst * w_dst + h * w_dst + w] = res.raw();
}
- dst[r * h_dst * w_dst + h * w_dst + w] = mul(avg_val, invpool_fp).raw();
}
}
}
diff --git a/tests/validation/NEON/PoolingLayer.cpp b/tests/validation/NEON/PoolingLayer.cpp
index 98ec478267..5ebbc1bc96 100644
--- a/tests/validation/NEON/PoolingLayer.cpp
+++ b/tests/validation/NEON/PoolingLayer.cpp
@@ -48,7 +48,7 @@ const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), fra
framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
/** Input data set for quantized data types */
-const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })),
+const auto PoolingLayerDatasetQS = combine(combine(framework::dataset::make("PoolingType", { PoolingType::MAX, PoolingType::AVG }), framework::dataset::make("PoolingSize", { 2, 3 })),
framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) }));
constexpr AbsoluteTolerance<float> tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */