From a09de0c8b2ed0f1481502d3b023375609362d9e3 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Fri, 1 Sep 2017 20:41:12 +0100 Subject: COMPMID-415: Rename and move tests The boost validation is now "standalone" in validation_old and builds as arm_compute_validation_old. The new validation builds now as arm_compute_validation. Change-Id: Ib93ba848a25680ac60afb92b461d574a0757150d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86187 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/validation/NEON/BatchNormalizationLayer.cpp | 258 ---------------------- 1 file changed, 258 deletions(-) delete mode 100644 tests/validation/NEON/BatchNormalizationLayer.cpp (limited to 'tests/validation/NEON/BatchNormalizationLayer.cpp') diff --git a/tests/validation/NEON/BatchNormalizationLayer.cpp b/tests/validation/NEON/BatchNormalizationLayer.cpp deleted file mode 100644 index 9898beb7db..0000000000 --- a/tests/validation/NEON/BatchNormalizationLayer.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (c) 2017 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 "NEON/Accessor.h" -#include "TypePrinter.h" -#include "dataset/BatchNormalizationLayerDataset.h" -#include "tests/Globals.h" -#include "tests/NEON/Helper.h" -#include "tests/Utils.h" -#include "tests/validation/Helpers.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/runtime/NEON/functions/NEBatchNormalizationLayer.h" - -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_qs8 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ -const float tolerance_qs16 = 6; /**< Tolerance value for comparing reference's output against quantized implementation's output */ -const float tolerance_f32 = 1e-05f; /**< Tolerance value for comparing reference's output against floating point implementation's output */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const float tolerance_f16 = 0.01f; /**< Tolerance value for comparing reference's output against half precision floating point implementation's output */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -/** Compute Neon batch normalization function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt Data type of input and output tensors. - * @param[in] norm_info Normalization Layer information. - * - * @return Computed output tensor. - */ -Tensor compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position = 0) -{ - // Create tensors - Tensor src = create_tensor(shape0, dt, 1, fixed_point_position); - Tensor dst = create_tensor(shape0, dt, 1, fixed_point_position); - Tensor mean = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor var = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor beta = create_tensor(shape1, dt, 1, fixed_point_position); - Tensor gamma = create_tensor(shape1, dt, 1, fixed_point_position); - - // Create and configure function - NEBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, epsilon); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - mean.allocator()->allocate(); - var.allocator()->allocate(); - beta.allocator()->allocate(); - gamma.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - BOOST_TEST(!mean.info()->is_resizable()); - BOOST_TEST(!var.info()->is_resizable()); - BOOST_TEST(!beta.info()->is_resizable()); - BOOST_TEST(!gamma.info()->is_resizable()); - - // Fill tensors - switch(dt) - { - case DataType::QS8: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } - case DataType::QS16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(fixed_point_position); - std::uniform_int_distribution<> distribution(bounds.first, bounds.second); - std::uniform_int_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } -#ifdef ARM_COMPUTE_ENABLE_FP16 - case DataType::F16: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - case DataType::F32: - { - const std::pair bounds = get_batchnormalization_layer_test_bounds(); - std::uniform_real_distribution<> distribution(bounds.first, bounds.second); - std::uniform_real_distribution<> distribution_var(0, bounds.second); - test::fill_tensors(distribution, { 0, 1, 3, 4 }, &src, &mean, &beta, &gamma); - test::fill_tensors(distribution_var, { 0 }, &var); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - break; - } - } - - // Compute function - norm.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(BatchNormalizationLayer) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16, DataType::F32 }), obj, dt) -{ - // Set fixed point position data type allowed - int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(obj.shape0, dt, 1, fixed_point_position); - Tensor dst = create_tensor(obj.shape0, dt, 1, fixed_point_position); - Tensor mean = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor var = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor beta = create_tensor(obj.shape1, dt, 1, fixed_point_position); - Tensor gamma = create_tensor(obj.shape1, dt, 1, fixed_point_position); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - BOOST_TEST(mean.info()->is_resizable()); - BOOST_TEST(var.info()->is_resizable()); - BOOST_TEST(beta.info()->is_resizable()); - BOOST_TEST(gamma.info()->is_resizable()); - - // Create and configure function - NEBatchNormalizationLayer norm; - norm.configure(&src, &dst, &mean, &var, &beta, &gamma, obj.epsilon); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(obj.shape0); - const ValidRegion valid_region_vec = shape_to_valid_region(obj.shape1); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - validate(mean.info()->valid_region(), valid_region_vec); - validate(var.info()->valid_region(), valid_region_vec); - validate(beta.info()->valid_region(), valid_region_vec); - validate(gamma.info()->valid_region(), valid_region_vec); -} - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F32), - obj, dt) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f32, 0); -} -BOOST_AUTO_TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::F16), - obj, dt) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f16, 0); -} -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_AUTO_TEST_SUITE(QS8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS8) * boost::unit_test::data::xrange(1, 6), - obj, dt, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_qs8); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(QS16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(Random, - RandomBatchNormalizationLayerDataset() * boost::unit_test::data::make(DataType::QS16) * boost::unit_test::data::xrange(1, 14), - obj, dt, fixed_point_position) -{ - // Compute function - Tensor dst = compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_batch_normalization_layer(obj.shape0, obj.shape1, dt, obj.epsilon, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_qs16); -} -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ -- cgit v1.2.1