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/FullyConnectedLayer.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/validation/reference/FullyConnectedLayer.cpp') diff --git a/tests/validation/reference/FullyConnectedLayer.cpp b/tests/validation/reference/FullyConnectedLayer.cpp index 9aecd6cf14..908c583161 100644 --- a/tests/validation/reference/FullyConnectedLayer.cpp +++ b/tests/validation/reference/FullyConnectedLayer.cpp @@ -49,11 +49,12 @@ void vector_matrix_multiply(const SimpleTensor &src, const SimpleTensor &w const T *weights_ptr = weights.data(); const TB *bias_ptr = bias.data(); T *dst_ptr = dst.data() + offset_dst; - +#if defined(_OPENMP) + #pragma omp parallel for +#endif /* _OPENMP */ for(int y = 0; y < rows_weights; ++y) { - dst_ptr[y] = std::inner_product(src_ptr, src_ptr + cols_weights, weights_ptr, static_cast(0)) + bias_ptr[y]; - weights_ptr += cols_weights; + dst_ptr[y] = std::inner_product(src_ptr, src_ptr + cols_weights, &weights_ptr[cols_weights * y], static_cast(0)) + bias_ptr[y]; } } @@ -85,7 +86,9 @@ void vector_matrix_multiply(const SimpleTensor &src, const SimpleTensor &w const int min = std::numeric_limits::lowest(); const int max = std::numeric_limits::max(); - +#if defined(_OPENMP) + #pragma omp parallel for +#endif /* _OPENMP */ for(int y = 0; y < rows_weights; ++y) { // Reset accumulator @@ -93,7 +96,7 @@ void vector_matrix_multiply(const SimpleTensor &src, const SimpleTensor &w for(int x = 0; x < cols_weights; ++x) { - acc += (src_ptr[x] + input_offset) * (weights_ptr[x] + weights_offset); + acc += (src_ptr[x] + input_offset) * (weights_ptr[x + y * cols_weights] + weights_offset); } // Accumulate the bias @@ -104,8 +107,6 @@ void vector_matrix_multiply(const SimpleTensor &src, const SimpleTensor &w // Store the result dst_ptr[y] = static_cast(acc); - - weights_ptr += cols_weights; } } } // namespace -- cgit v1.2.1