aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/fixtures/BatchNormalizationLayerFixture.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/validation/fixtures/BatchNormalizationLayerFixture.h')
-rw-r--r--tests/validation/fixtures/BatchNormalizationLayerFixture.h43
1 files changed, 23 insertions, 20 deletions
diff --git a/tests/validation/fixtures/BatchNormalizationLayerFixture.h b/tests/validation/fixtures/BatchNormalizationLayerFixture.h
index 359752f14e..54a0ed9e09 100644
--- a/tests/validation/fixtures/BatchNormalizationLayerFixture.h
+++ b/tests/validation/fixtures/BatchNormalizationLayerFixture.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 ARM Limited.
+ * Copyright (c) 2017-2021, 2023 Arm Limited.
*
* SPDX-License-Identifier: MIT
*
@@ -44,7 +44,6 @@ template <typename TensorType, typename AccessorType, typename FunctionType, typ
class BatchNormalizationLayerValidationFixture : public framework::Fixture
{
public:
- template <typename...>
void setup(TensorShape shape0, TensorShape shape1, float epsilon, bool use_beta, bool use_gamma, ActivationLayerInfo act_info, DataType dt, DataLayout data_layout)
{
_data_type = dt;
@@ -59,10 +58,14 @@ protected:
template <typename U>
void fill(U &&src_tensor, U &&mean_tensor, U &&var_tensor, U &&beta_tensor, U &&gamma_tensor)
{
- const float min_bound = -1.f;
- const float max_bound = 1.f;
- std::uniform_real_distribution<> distribution(min_bound, max_bound);
- std::uniform_real_distribution<> distribution_var(0, max_bound);
+ 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_16bit<T>, std::uniform_real_distribution<T>>::type;
+
+ const T min_bound = T(-1.f);
+ const T max_bound = T(1.f);
+ DistributionType distribution{ min_bound, max_bound };
+ DistributionType distribution_var{ T(0.f), max_bound };
+
library->fill(src_tensor, distribution, 0);
library->fill(mean_tensor, distribution, 1);
library->fill(var_tensor, distribution_var, 0);
@@ -73,7 +76,7 @@ protected:
else
{
// Fill with default value 0.f
- library->fill_tensor_value(beta_tensor, 0.f);
+ library->fill_tensor_value(beta_tensor, T(0.f));
}
if(_use_gamma)
{
@@ -82,7 +85,7 @@ protected:
else
{
// Fill with default value 1.f
- library->fill_tensor_value(gamma_tensor, 1.f);
+ library->fill_tensor_value(gamma_tensor, T(1.f));
}
}
@@ -107,12 +110,12 @@ protected:
TensorType *gamma_ptr = _use_gamma ? &gamma : nullptr;
norm.configure(&src, &dst, &mean, &var, beta_ptr, gamma_ptr, epsilon, act_info);
- ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(mean.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(var.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(beta.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(gamma.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_ASSERT(src.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(dst.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(mean.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(var.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(beta.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(gamma.info()->is_resizable());
// Allocate tensors
src.allocator()->allocate();
@@ -122,12 +125,12 @@ protected:
beta.allocator()->allocate();
gamma.allocator()->allocate();
- ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(!mean.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(!var.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(!beta.info()->is_resizable(), framework::LogLevel::ERRORS);
- ARM_COMPUTE_EXPECT(!gamma.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_ASSERT(!src.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!dst.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!mean.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!var.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!beta.info()->is_resizable());
+ ARM_COMPUTE_ASSERT(!gamma.info()->is_resizable());
// Fill tensors
fill(AccessorType(src), AccessorType(mean), AccessorType(var), AccessorType(beta), AccessorType(gamma));