aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h
diff options
context:
space:
mode:
authorGiorgio Arena <giorgio.arena@arm.com>2020-12-17 16:47:07 +0000
committerGiorgio Arena <giorgio.arena@arm.com>2021-01-07 16:41:34 +0000
commit4bdd177c75789451cad9ba1ecf929214ed75c009 (patch)
treea6a8ea96045a13af4b29e9c81014516dfe929715 /tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h
parent4d9383e179ed6be8cdb117e6353a0dea1c40be93 (diff)
downloadComputeLibrary-4bdd177c75789451cad9ba1ecf929214ed75c009.tar.gz
Fix fill() for FP data type in fixtures - Part 2
Resolves: COMPMID-4056 Signed-off-by: Giorgio Arena <giorgio.arena@arm.com> Change-Id: I6623eb9c0e66e52af4e0e9fb386031f4a09125b7 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4722 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/fixtures/BatchNormalizationLayerFusionFixture.h')
-rw-r--r--tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h b/tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h
index 2df7f47ff3..3f7f97a29c 100644
--- a/tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h
+++ b/tests/validation/fixtures/BatchNormalizationLayerFusionFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018 Arm Limited.
+ * Copyright (c) 2018-2020 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -65,16 +65,19 @@ protected:
template <typename U>
void fill(U &&src, U &&w_tensor, U &&b_tensor, U &&mean_tensor, U &&var_tensor, U &&beta_tensor, U &&gamma_tensor)
{
- std::uniform_real_distribution<> distribution(-1.f, 1.f);
- std::uniform_real_distribution<> distribution_gz(0, 1.f);
+ static_assert(std::is_floating_point<T>::value || std::is_same<T, half>::value, "Only floating point data types supported.");
+ using DistributionType = typename std::conditional<std::is_same<T, half>::value, arm_compute::utils::uniform_real_distribution_fp16, std::uniform_real_distribution<T>>::type;
+
+ DistributionType distribution{ T(-1.f), T(1.f) };
+ DistributionType distribution_gz{ T(0.f), T(1.f) };
library->fill(src, distribution, 0);
library->fill(w_tensor, distribution, 1);
library->fill(mean_tensor, distribution, 2);
library->fill(var_tensor, distribution_gz, 3);
- _use_conv_b ? library->fill(b_tensor, distribution, 4) : library->fill_tensor_value(b_tensor, 0.f);
- _use_beta ? library->fill(beta_tensor, distribution, 5) : library->fill_tensor_value(beta_tensor, 0.f);
- _use_gamma ? library->fill(gamma_tensor, distribution, 6) : library->fill_tensor_value(gamma_tensor, 1.f);
+ _use_conv_b ? library->fill(b_tensor, distribution, 4) : library->fill_tensor_value(b_tensor, T(0.f));
+ _use_beta ? library->fill(beta_tensor, distribution, 5) : library->fill_tensor_value(beta_tensor, T(0.f));
+ _use_gamma ? library->fill(gamma_tensor, distribution, 6) : library->fill_tensor_value(gamma_tensor, T(1.f));
}
TensorType compute_target(TensorShape src_shape, TensorShape w_shape, TensorShape b_shape, TensorShape dst_shape, PadStrideInfo info, float epsilon)