aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/reference/FullyConnectedLayer.cpp
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2020-04-08 14:10:15 +0100
committerMichalis Spyrou <michalis.spyrou@arm.com>2020-04-17 14:20:01 +0000
commitd1d7722cfc5ee130115d8d195068a98b16102a21 (patch)
treef68f3ecca02ab4edde90189266fa186ec1a69474 /tests/validation/reference/FullyConnectedLayer.cpp
parent4c6bd514a8d424a29b776754f1b3426fa3a8c339 (diff)
downloadComputeLibrary-d1d7722cfc5ee130115d8d195068a98b16102a21.tar.gz
COMPMID-3314: Enable OpenMP in the reference tests
Change-Id: I05b5fedb998317144e0dd13a6377a97207b27f46 Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3024 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/reference/FullyConnectedLayer.cpp')
-rw-r--r--tests/validation/reference/FullyConnectedLayer.cpp15
1 files changed, 8 insertions, 7 deletions
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<T> &src, const SimpleTensor<T> &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<T>(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<T>(0)) + bias_ptr[y];
}
}
@@ -85,7 +86,9 @@ void vector_matrix_multiply(const SimpleTensor<T> &src, const SimpleTensor<T> &w
const int min = std::numeric_limits<T>::lowest();
const int max = std::numeric_limits<T>::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<T> &src, const SimpleTensor<T> &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<T> &src, const SimpleTensor<T> &w
// Store the result
dst_ptr[y] = static_cast<T>(acc);
-
- weights_ptr += cols_weights;
}
}
} // namespace