From d1d7722cfc5ee130115d8d195068a98b16102a21 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Wed, 8 Apr 2020 14:10:15 +0100 Subject: COMPMID-3314: Enable OpenMP in the reference tests Change-Id: I05b5fedb998317144e0dd13a6377a97207b27f46 Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3024 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- tests/validation/reference/InstanceNormalizationLayer.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/validation/reference/InstanceNormalizationLayer.cpp') diff --git a/tests/validation/reference/InstanceNormalizationLayer.cpp b/tests/validation/reference/InstanceNormalizationLayer.cpp index ad0ac1be68..339549723d 100644 --- a/tests/validation/reference/InstanceNormalizationLayer.cpp +++ b/tests/validation/reference/InstanceNormalizationLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 ARM Limited. + * Copyright (c) 2019-2020 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -46,12 +46,14 @@ SimpleTensor instance_normalization(const SimpleTensor &src, float gamma, const size_t h_size = src.shape()[1]; const size_t c_size = src.shape()[2]; const size_t n_size = src.shape()[3]; - +#if defined(_OPENMP) + #pragma omp parallel for collapse(2) +#endif /* _OPENMP */ for(size_t n_i = 0; n_i < n_size; ++n_i) { for(size_t c_i = 0; c_i < c_size; ++c_i) { - float sum_h_w = 0; + float sum_h_w = 0; float sum_sq_h_w = 0; for(size_t h_i = 0; h_i < h_size; ++h_i) @@ -60,13 +62,14 @@ SimpleTensor instance_normalization(const SimpleTensor &src, float gamma, { float val = src[coord2index(src.shape(), Coordinates(w_i, h_i, c_i, n_i))]; sum_h_w += val; - sum_sq_h_w += val*val; + sum_sq_h_w += val * val; } } //Compute mean const float mean_h_w = sum_h_w / (h_size * w_size); //Compute variance - const float var_h_w = sum_sq_h_w / (h_size * w_size) - mean_h_w * mean_h_w;; + const float var_h_w = sum_sq_h_w / (h_size * w_size) - mean_h_w * mean_h_w; + ; //Apply mean for(size_t h_i = 0; h_i < h_size; ++h_i) -- cgit v1.2.1