aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGian Marco Iodice <gianmarco.iodice@arm.com>2019-06-10 14:46:49 +0100
committerGian Marco Iodice <gianmarco.iodice@arm.com>2019-06-11 12:08:08 +0000
commit761c8d02ff875877db7aa7c850cf8d128592e822 (patch)
tree10871f3dccfa262d4a051d3d88b899be6acac0a2 /tests
parentd5134364fc4ca40ea65635192e7959327d690a01 (diff)
downloadComputeLibrary-761c8d02ff875877db7aa7c850cf8d128592e822.tar.gz
COMPMID-2398: Add test for CLFuseBatchNormalizationLayer
Change-Id: I786df628ce15fc33fc42c9437fe82972e02e3b16 Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Reviewed-on: https://review.mlplatform.org/c/1317 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/validation/CL/FuseBatchNormalization.cpp147
-rw-r--r--tests/validation/fixtures/FuseBatchNormalizationFixture.h204
-rw-r--r--tests/validation/reference/FuseBatchNormalization.cpp111
-rw-r--r--tests/validation/reference/FuseBatchNormalization.h51
4 files changed, 513 insertions, 0 deletions
diff --git a/tests/validation/CL/FuseBatchNormalization.cpp b/tests/validation/CL/FuseBatchNormalization.cpp
new file mode 100644
index 0000000000..92d63c0c3d
--- /dev/null
+++ b/tests/validation/CL/FuseBatchNormalization.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "arm_compute/runtime/CL/functions/CLFuseBatchNormalization.h"
+#include "tests/CL/CLAccessor.h"
+#include "tests/Globals.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "tests/validation/Validation.h"
+#include "tests/validation/fixtures/FuseBatchNormalizationFixture.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace
+{
+AbsoluteTolerance<float> absolute_tolerance_f32(0.001f);
+AbsoluteTolerance<float> absolute_tolerance_f16(0.2f);
+} // namespace
+
+template <typename T>
+using CLFuseBatchNormalizationConvFixture = FuseBatchNormalizationFixture<CLTensor, CLAccessor, CLFuseBatchNormalization, 4, T>;
+
+// *INDENT-OFF*
+// clang-format off
+
+/** Shapes to test - Precommit */
+const auto shape_conv_values_precommit = concat(datasets::Small4DShapes(), datasets::Small3DShapes());
+
+/** Shapes to test - Nightly */
+const auto shape_conv_values_nightly = concat(datasets::Large4DShapes(), datasets::Large3DShapes());
+
+/** Data layout to test */
+const auto data_layout_values = framework::dataset::make("DataLayout", { DataLayout::NHWC, DataLayout::NCHW });
+
+/** In-place flags to test */
+const auto in_place_values = framework::dataset::make("InPlace", { true, false });
+
+/** With bias flags to test */
+const auto with_bias_values = framework::dataset::make("WithBias", { true, false });
+
+/** With gamma flags to test */
+const auto with_gamma_values = framework::dataset::make("WithGamma", { true, false });
+
+/** With beta flags to test */
+const auto with_beta_values = framework::dataset::make("WithBeta", { true, false });
+
+TEST_SUITE(CL)
+TEST_SUITE(FuseBatchNormalization)
+TEST_SUITE(Convolution)
+TEST_SUITE(Float)
+TEST_SUITE(FP32)
+FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::PRECOMMIT,
+ combine(combine(combine(combine(combine(combine(
+ shape_conv_values_precommit,
+ framework::dataset::make("DataType", { DataType::F32 })),
+ data_layout_values),
+ in_place_values),
+ with_bias_values),
+ with_gamma_values),
+ with_beta_values))
+{
+ // Validate outputs
+ validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32);
+ validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32);
+}
+
+FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<float>, framework::DatasetMode::NIGHTLY,
+ combine(combine(combine(combine(combine(combine(
+ shape_conv_values_nightly,
+ framework::dataset::make("DataType", { DataType::F32 })),
+ data_layout_values),
+ in_place_values),
+ with_bias_values),
+ with_gamma_values),
+ with_beta_values))
+{
+ // Validate outputs
+ validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f32);
+ validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f32);
+}
+
+TEST_SUITE_END() // FP32
+
+TEST_SUITE(FP16)
+FIXTURE_DATA_TEST_CASE(RunSmall, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::PRECOMMIT,
+ combine(combine(combine(combine(combine(combine(
+ shape_conv_values_precommit,
+ framework::dataset::make("DataType", { DataType::F16 })),
+ data_layout_values),
+ in_place_values),
+ with_bias_values),
+ with_gamma_values),
+ with_beta_values))
+{
+ // Validate outputs
+ validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16);
+ validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16);
+}
+
+FIXTURE_DATA_TEST_CASE(RunLarge, CLFuseBatchNormalizationConvFixture<half>, framework::DatasetMode::NIGHTLY,
+ combine(combine(combine(combine(combine(combine(
+ shape_conv_values_nightly,
+ framework::dataset::make("DataType", { DataType::F16 })),
+ data_layout_values),
+ in_place_values),
+ with_bias_values),
+ with_gamma_values),
+ with_beta_values))
+{
+ // Validate outputs
+ validate(CLAccessor(_target_w), _reference_w, absolute_tolerance_f16);
+ validate(CLAccessor(_target_b), _reference_b, absolute_tolerance_f16);
+}
+
+TEST_SUITE_END() // FP16
+TEST_SUITE_END() // Float
+TEST_SUITE_END() // Convolution
+TEST_SUITE_END() // FuseBatchNormalization
+TEST_SUITE_END() // CL
+} // namespace validation
+} // namespace test
+} // namespace arm_compute \ No newline at end of file
diff --git a/tests/validation/fixtures/FuseBatchNormalizationFixture.h b/tests/validation/fixtures/FuseBatchNormalizationFixture.h
new file mode 100644
index 0000000000..864d627ed7
--- /dev/null
+++ b/tests/validation/fixtures/FuseBatchNormalizationFixture.h
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_FIXTURE
+#define ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_FIXTURE
+
+#include "arm_compute/core/TensorShape.h"
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/CL/functions/CLFuseBatchNormalization.h"
+#include "tests/AssetsLibrary.h"
+#include "tests/Globals.h"
+#include "tests/IAccessor.h"
+#include "tests/framework/Asserts.h"
+#include "tests/framework/Fixture.h"
+#include "tests/validation/Helpers.h"
+#include "tests/validation/reference/FuseBatchNormalization.h"
+
+#include <tuple>
+#include <utility>
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+template <typename TensorType, typename AccessorType, typename FunctionType, int dims_weights, typename T>
+class FuseBatchNormalizationFixture : public framework::Fixture
+{
+public:
+ template <typename...>
+ void setup(TensorShape shape_w, DataType data_type, DataLayout data_layout, bool in_place, bool with_bias, bool with_gamma, bool with_beta)
+ {
+ std::tie(_target_w, _target_b) = compute_target(shape_w, data_type, data_layout, in_place, with_bias, with_gamma, with_beta);
+ std::tie(_reference_w, _reference_b) = compute_reference(shape_w, data_type, data_layout, with_bias, with_gamma, with_beta);
+ }
+
+protected:
+ template <typename U>
+ void fill(U &&tensor, int i, float min, float max)
+ {
+ library->fill_tensor_uniform(tensor, i, min, max);
+ }
+
+ std::pair<TensorType, TensorType> compute_target(TensorShape shape_w, DataType data_type, DataLayout data_layout, bool in_place, bool with_bias, bool with_gamma, bool with_beta)
+ {
+ const TensorShape shape_v(shape_w[dims_weights - 1]);
+
+ if(data_layout == DataLayout::NHWC)
+ {
+ permute(shape_w, PermutationVector(2U, 0U, 1U));
+ }
+
+ const bool in_place_w = in_place;
+ const bool in_place_b = with_bias ? in_place : false;
+
+ // Create tensors
+ TensorType w = create_tensor<TensorType>(shape_w, data_type, 1, QuantizationInfo(), data_layout);
+ TensorType b = create_tensor<TensorType>(shape_v, data_type);
+ TensorType mean = create_tensor<TensorType>(shape_v, data_type);
+ TensorType var = create_tensor<TensorType>(shape_v, data_type);
+ TensorType w_fused = create_tensor<TensorType>(shape_w, data_type, 1, QuantizationInfo(), data_layout);
+ TensorType b_fused = create_tensor<TensorType>(shape_v, data_type);
+ TensorType beta = create_tensor<TensorType>(shape_v, data_type);
+ TensorType gamma = create_tensor<TensorType>(shape_v, data_type);
+
+ auto b_to_use = with_bias ? &b : nullptr;
+ auto gamma_to_use = with_gamma ? &gamma : nullptr;
+ auto beta_to_use = with_beta ? &beta : nullptr;
+ auto w_fused_to_use = in_place_w ? nullptr : &w_fused;
+ auto b_fused_to_use = in_place_b ? nullptr : &b_fused;
+
+ // Create and configure function
+ FunctionType fuse_batch_normalization;
+ fuse_batch_normalization.configure(&w, &mean, &var, w_fused_to_use, b_fused_to_use, b_to_use, beta_to_use, gamma_to_use, _epsilon);
+
+ ARM_COMPUTE_EXPECT(w.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(b.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(w_fused.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(b_fused.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);
+
+ // Allocate tensors
+ w.allocator()->allocate();
+ b.allocator()->allocate();
+ mean.allocator()->allocate();
+ var.allocator()->allocate();
+ w_fused.allocator()->allocate();
+ b_fused.allocator()->allocate();
+ beta.allocator()->allocate();
+ gamma.allocator()->allocate();
+
+ ARM_COMPUTE_EXPECT(!w.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(!b.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(!w_fused.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(!b_fused.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);
+
+ // Fill tensors
+ fill(AccessorType(w), 0U, -1.0f, 1.0f);
+ fill(AccessorType(b), 1U, -1.0f, 1.0f);
+ fill(AccessorType(mean), 2U, -1.0f, 1.0f);
+ fill(AccessorType(var), 3U, 0.0f, 1.0f);
+ fill(AccessorType(beta), 4U, -1.0f, 1.0f);
+ fill(AccessorType(gamma), 5U, -1.0f, 1.0f);
+
+ // Compute function
+ fuse_batch_normalization.run();
+
+ return std::make_pair(std::move(in_place_w ? w : w_fused), std::move(in_place_b ? b : b_fused));
+ }
+
+ std::pair<SimpleTensor<T>, SimpleTensor<T>> compute_reference(TensorShape shape_w, DataType data_type, DataLayout data_layout, bool with_bias, bool with_gamma, bool with_beta)
+ {
+ const TensorShape shape_v(shape_w[dims_weights - 1]);
+
+ SimpleTensor<T> w{ shape_w, data_type };
+ SimpleTensor<T> b{ shape_v, data_type };
+ SimpleTensor<T> mean{ shape_v, data_type };
+ SimpleTensor<T> var{ shape_v, data_type };
+ SimpleTensor<T> w_fused{ shape_w, data_type };
+ SimpleTensor<T> b_fused{ shape_v, data_type };
+ SimpleTensor<T> beta{ shape_v, data_type };
+ SimpleTensor<T> gamma{ shape_v, data_type };
+
+ // Fill reference tensor
+ fill(w, 0U, -1.0f, 1.0f);
+ fill(b, 1U, -1.0f, 1.0f);
+ fill(mean, 2U, -1.0f, 1.0f);
+ fill(var, 3U, 0.0f, 1.0f);
+ fill(beta, 4U, -1.0f, 1.0f);
+ fill(gamma, 5U, -1.0f, 1.0f);
+
+ if(!with_bias)
+ {
+ // Fill with zeros
+ fill(b, 0U, 0.0f, 0.0f);
+ }
+
+ if(!with_gamma)
+ {
+ // Fill with ones
+ fill(gamma, 0U, 1.0f, 1.0f);
+ }
+
+ if(!with_beta)
+ {
+ // Fill with zeros
+ fill(beta, 0U, 0.0f, 0.0f);
+ }
+
+ switch(dims_weights)
+ {
+ case 3:
+ // Weights for depth wise convolution layer
+ reference::fuse_batch_normalization_dwc_layer(w, mean, var, w_fused, b_fused, b, beta, gamma, _epsilon);
+ break;
+ case 4:
+ // Weights for convolution layer
+ reference::fuse_batch_normalization_conv_layer(w, mean, var, w_fused, b_fused, b, beta, gamma, _epsilon);
+ break;
+ default:
+ ARM_COMPUTE_ERROR("Not supported number of dimensions for the input weights tensor");
+ }
+
+ return std::make_pair(std::move(w_fused), std::move(b_fused));
+ }
+
+ const float _epsilon{ 0.0001f };
+ TensorType _target_w{};
+ TensorType _target_b{};
+ SimpleTensor<T> _reference_w{};
+ SimpleTensor<T> _reference_b{};
+};
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_FIXTURE */
diff --git a/tests/validation/reference/FuseBatchNormalization.cpp b/tests/validation/reference/FuseBatchNormalization.cpp
new file mode 100644
index 0000000000..df12b25912
--- /dev/null
+++ b/tests/validation/reference/FuseBatchNormalization.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "FuseBatchNormalization.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+template <typename T>
+void fuse_batch_normalization_dwc_layer(const SimpleTensor<T> &w, const SimpleTensor<T> &mean, const SimpleTensor<T> &var, SimpleTensor<T> &w_fused, SimpleTensor<T> &b_fused, const SimpleTensor<T> &b,
+ const SimpleTensor<T> &beta, const SimpleTensor<T> &gamma, float epsilon)
+{
+ const auto *w_data = w.data();
+ const auto *b_data = b.data();
+
+ auto *w_fused_data = w_fused.data();
+ auto *b_fused_data = b_fused.data();
+
+ const unsigned int width = w.shape()[0];
+ const unsigned int height = w.shape()[1];
+ const unsigned int dim2 = w.shape()[2];
+
+ for(unsigned int b = 0; b < dim2; ++b)
+ {
+ const auto mean_val = mean.data()[b];
+ const auto var_val = var.data()[b];
+ const auto beta_val = beta.data()[b];
+ const auto gamma_val = gamma.data()[b];
+
+ for(unsigned int i = 0; i < width * height; ++i)
+ {
+ unsigned int index = i + b * width * height;
+
+ w_fused_data[index] = (gamma_val * (w_data[index])) / sqrt(var_val + epsilon);
+ }
+
+ b_fused_data[b] = (b_data[b] - mean_val) / sqrt(var_val + epsilon) * gamma_val + beta_val;
+ }
+}
+
+template <typename T>
+void fuse_batch_normalization_conv_layer(const SimpleTensor<T> &w, const SimpleTensor<T> &mean, const SimpleTensor<T> &var, SimpleTensor<T> &w_fused, SimpleTensor<T> &b_fused,
+ const SimpleTensor<T> &b,
+ const SimpleTensor<T> &beta, const SimpleTensor<T> &gamma, float epsilon)
+{
+ const auto *w_data = w.data();
+ const auto *b_data = b.data();
+
+ auto *w_fused_data = w_fused.data();
+ auto *b_fused_data = b_fused.data();
+
+ const unsigned int width = w.shape()[0];
+ const unsigned int height = w.shape()[1];
+ const unsigned int dim2 = w.shape()[2];
+ const unsigned int dim3 = w.shape()[3];
+
+ for(unsigned int b = 0; b < dim3; ++b)
+ {
+ const auto mean_val = mean.data()[b];
+ const auto var_val = var.data()[b];
+ const auto beta_val = beta.data()[b];
+ const auto gamma_val = gamma.data()[b];
+
+ for(unsigned int i = 0; i < width * height * dim2; ++i)
+ {
+ unsigned int index = i + b * width * height * dim2;
+
+ w_fused_data[index] = (gamma_val * (w_data[index])) / sqrt(var_val + epsilon);
+ }
+
+ b_fused_data[b] = (b_data[b] - mean_val) / sqrt(var_val + epsilon) * gamma_val + beta_val;
+ }
+}
+
+template void fuse_batch_normalization_dwc_layer(const SimpleTensor<float> &w, const SimpleTensor<float> &mean, const SimpleTensor<float> &var, SimpleTensor<float> &w_fused,
+ SimpleTensor<float> &b_fused, const SimpleTensor<float> &b, const SimpleTensor<float> &beta, const SimpleTensor<float> &gamma, float epsilon);
+template void fuse_batch_normalization_dwc_layer(const SimpleTensor<half> &w, const SimpleTensor<half> &mean, const SimpleTensor<half> &var, SimpleTensor<half> &w_fused, SimpleTensor<half> &b_fused,
+ const SimpleTensor<half> &b, const SimpleTensor<half> &beta, const SimpleTensor<half> &gamma, float epsilon);
+template void fuse_batch_normalization_conv_layer(const SimpleTensor<float> &w, const SimpleTensor<float> &mean, const SimpleTensor<float> &var, SimpleTensor<float> &w_fused,
+ SimpleTensor<float> &b_fused, const SimpleTensor<float> &b, const SimpleTensor<float> &beta, const SimpleTensor<float> &gamma, float epsilon);
+template void fuse_batch_normalization_conv_layer(const SimpleTensor<half> &w, const SimpleTensor<half> &mean, const SimpleTensor<half> &var, SimpleTensor<half> &w_fused, SimpleTensor<half> &b_fused,
+ const SimpleTensor<half> &b, const SimpleTensor<half> &beta, const SimpleTensor<half> &gamma, float epsilon);
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/validation/reference/FuseBatchNormalization.h b/tests/validation/reference/FuseBatchNormalization.h
new file mode 100644
index 0000000000..1575fc0acc
--- /dev/null
+++ b/tests/validation/reference/FuseBatchNormalization.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2019 ARM Limited.
+ *
+ * SPDX-License-Identifier: MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef __ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_H__
+#define __ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_H__
+
+#include "tests/SimpleTensor.h"
+#include "tests/validation/Helpers.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace validation
+{
+namespace reference
+{
+template <typename T>
+void fuse_batch_normalization_dwc_layer(const SimpleTensor<T> &w, const SimpleTensor<T> &mean, const SimpleTensor<T> &var, SimpleTensor<T> &w_fused, SimpleTensor<T> &b_fused, const SimpleTensor<T> &b,
+ const SimpleTensor<T> &beta, const SimpleTensor<T> &gamma, float epsilon);
+
+template <typename T>
+void fuse_batch_normalization_conv_layer(const SimpleTensor<T> &w, const SimpleTensor<T> &mean, const SimpleTensor<T> &var, SimpleTensor<T> &w_fused, SimpleTensor<T> &b_fused,
+ const SimpleTensor<T> &b,
+ const SimpleTensor<T> &beta, const SimpleTensor<T> &gamma, float epsilon);
+
+} // namespace reference
+} // namespace validation
+} // namespace test
+} // namespace arm_compute
+#endif // __ARM_COMPUTE_TEST_FUSEBATCHNORMALIZATION_H__