24 #ifndef ARM_COMPUTE_TEST_BATCH_NORMALIZATION_LAYER_FIXTURE 25 #define ARM_COMPUTE_TEST_BATCH_NORMALIZATION_LAYER_FIXTURE 43 template <
typename TensorType,
typename AccessorType,
typename FunctionType,
typename T>
47 template <
typename...>
50 _fractional_bits = fractional_bits;
52 _target = compute_target(shape0, shape1, epsilon, act_info, dt, fractional_bits);
53 _reference = compute_reference(shape0, shape1, epsilon, act_info, dt, fractional_bits);
58 void fill(
U &&src_tensor,
U &&mean_tensor,
U &&var_tensor,
U &&beta_tensor,
U &&gamma_tensor)
62 float min_bound = 0.f;
63 float max_bound = 0.f;
64 std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds<T>();
65 std::uniform_real_distribution<> distribution(min_bound, max_bound);
66 std::uniform_real_distribution<> distribution_var(0, max_bound);
67 library->fill(src_tensor, distribution, 0);
68 library->fill(mean_tensor, distribution, 1);
69 library->fill(var_tensor, distribution_var, 0);
70 library->fill(beta_tensor, distribution, 3);
71 library->fill(gamma_tensor, distribution, 4);
77 std::tie(min_bound, max_bound) = get_batchnormalization_layer_test_bounds<T>(_fractional_bits);
78 std::uniform_int_distribution<> distribution(min_bound, max_bound);
79 std::uniform_int_distribution<> distribution_var(0, max_bound);
80 library->fill(src_tensor, distribution, 0);
81 library->fill(mean_tensor, distribution, 1);
82 library->fill(var_tensor, distribution_var, 0);
83 library->fill(beta_tensor, distribution, 3);
84 library->fill(gamma_tensor, distribution, 4);
91 TensorType
src = create_tensor<TensorType>(shape0, dt, 1, fixed_point_position);
92 TensorType
dst = create_tensor<TensorType>(shape0, dt, 1, fixed_point_position);
93 TensorType mean = create_tensor<TensorType>(shape1, dt, 1, fixed_point_position);
94 TensorType var = create_tensor<TensorType>(shape1, dt, 1, fixed_point_position);
95 TensorType
beta = create_tensor<TensorType>(shape1, dt, 1, fixed_point_position);
96 TensorType gamma = create_tensor<TensorType>(shape1, dt, 1, fixed_point_position);
100 norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon, act_info);
110 src.allocator()->allocate();
111 dst.allocator()->allocate();
112 mean.allocator()->allocate();
113 var.allocator()->allocate();
114 beta.allocator()->allocate();
115 gamma.allocator()->allocate();
125 fill(AccessorType(src), AccessorType(mean), AccessorType(var), AccessorType(beta), AccessorType(gamma));
143 fill(ref_src, ref_mean, ref_var, ref_beta, ref_gamma);
148 TensorType _target{};
150 int _fractional_bits{};
154 template <
typename TensorType,
typename AccessorType,
typename FunctionType,
typename T>
158 template <
typename...>
Activation Layer Information class.
This file contains all available output stages for GEMMLowp on OpenCL.
std::unique_ptr< AssetsLibrary > library
void setup()
Setup function.
void setup(TensorShape shape0, TensorShape shape1, float epsilon, ActivationLayerInfo act_info, DataType dt)
SimpleTensor< T > batch_normalization_layer(const SimpleTensor< T > &src, const SimpleTensor< T > &mean, const SimpleTensor< T > &var, const SimpleTensor< T > &beta, const SimpleTensor< T > &gamma, float epsilon, ActivationLayerInfo act_info, int fixed_point_position)
Simple tensor object that stores elements in a consecutive chunk of memory.
ARM_COMPUTE_EXPECT(src.info() ->is_resizable(), framework::LogLevel::ERRORS)
void setup(TensorShape shape0, TensorShape shape1, float epsilon, ActivationLayerInfo act_info, DataType dt, int fractional_bits)
DataType
Available data types.
convolution configure & src
bool is_data_type_float(DataType dt)
Check if a given data type is of floating point type.