aboutsummaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
authorMoritz Pflanzer <moritz.pflanzer@arm.com>2017-07-21 17:36:33 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:16:42 +0100
commit572ade736ab344a62afa7da214cd9407fe53a281 (patch)
treeadc0b31c0e236b65822dcbc9fb45ce401cc6ead4 /tests/validation
parent8e6faf1e9f1af7a03441612c30644776e87fd235 (diff)
downloadComputeLibrary-572ade736ab344a62afa7da214cd9407fe53a281.tar.gz
COMPMID-415: Move ActivationLayer to new validation
Change-Id: I38ce20d95640f9c1baf699a095c35e592ad4339f Reviewed-on: http://mpd-gerrit.cambridge.arm.com/81115 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/CL/ActivationLayer.cpp282
-rw-r--r--tests/validation/NEON/ActivationLayer.cpp328
-rw-r--r--tests/validation/Reference.cpp50
-rw-r--r--tests/validation/Reference.h10
-rw-r--r--tests/validation/ReferenceCPP.cpp8
-rw-r--r--tests/validation/ReferenceCPP.h7
-rw-r--r--tests/validation/TensorOperations.h103
-rw-r--r--tests/validation/TensorVisitors.h20
8 files changed, 0 insertions, 808 deletions
diff --git a/tests/validation/CL/ActivationLayer.cpp b/tests/validation/CL/ActivationLayer.cpp
deleted file mode 100644
index a1e00b681b..0000000000
--- a/tests/validation/CL/ActivationLayer.cpp
+++ /dev/null
@@ -1,282 +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 "AssetsLibrary.h"
-#include "CL/CLAccessor.h"
-#include "Globals.h"
-#include "PaddingCalculator.h"
-#include "TypePrinter.h"
-#include "Utils.h"
-#include "validation/Datasets.h"
-#include "validation/Helpers.h"
-#include "validation/Reference.h"
-#include "validation/Validation.h"
-
-#include "arm_compute/core/Helpers.h"
-#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/CLTensor.h"
-#include "arm_compute/runtime/CL/CLTensorAllocator.h"
-#include "arm_compute/runtime/CL/functions/CLActivationLayer.h"
-
-#include "boost_wrapper.h"
-
-#include <random>
-#include <string>
-#include <tuple>
-
-using namespace arm_compute;
-using namespace arm_compute::test;
-using namespace arm_compute::test::validation;
-
-namespace
-{
-/** Define tolerance of the activation layer
- *
- * @param[in] activation The activation function used.
- * @param[in] fixed_point_position Number of bits for the fractional part..
- *
- * @return Tolerance depending on the activation function.
- */
-float activation_layer_tolerance(ActivationLayerInfo::ActivationFunction activation, int fixed_point_position = 0)
-{
- switch(activation)
- {
- case ActivationLayerInfo::ActivationFunction::LOGISTIC:
- case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
- case ActivationLayerInfo::ActivationFunction::SQRT:
- case ActivationLayerInfo::ActivationFunction::TANH:
- return (fixed_point_position != 0) ? 5.f : 0.00001f;
- break;
- default:
- return 0.f;
- }
-}
-
-/** Compute CL activation layer function.
- *
- * @param[in] in_place Compute the activation layer in-place.
- * @param[in] shape Shape of the input and output tensors.
- * @param[in] dt Shape Data type of tensors.
- * @param[in] act_info Activation layer information.
- * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of fixed point numbers.
- *
- * @return Computed output tensor.
- */
-CLTensor compute_activation_layer(bool in_place, const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0)
-{
- // Create tensors
- CLTensor src = create_tensor<CLTensor>(shape, dt, 1, fixed_point_position);
- CLTensor dst = create_tensor<CLTensor>(shape, dt, 1, fixed_point_position);
-
- // Create and configure function
- CLActivationLayer act_layer;
-
- if(in_place)
- {
- act_layer.configure(&src, nullptr, act_info);
- }
- else
- {
- act_layer.configure(&src, &dst, act_info);
- }
-
- // Allocate tensors
- src.allocator()->allocate();
- BOOST_TEST(!src.info()->is_resizable());
-
- if(!in_place)
- {
- dst.allocator()->allocate();
- BOOST_TEST(!dst.info()->is_resizable());
- }
-
- // Fill tensors
- if(dt == DataType::F32)
- {
- float min_bound = 0;
- float max_bound = 0;
- std::tie(min_bound, max_bound) = get_activation_layer_test_bounds<float>(act_info.activation());
- std::uniform_real_distribution<> distribution(min_bound, max_bound);
- library->fill(CLAccessor(src), distribution, 0);
- }
- else
- {
- int min_bound = 0;
- int max_bound = 0;
- if(dt == DataType::QS8)
- {
- std::tie(min_bound, max_bound) = get_activation_layer_test_bounds<int8_t>(act_info.activation(), fixed_point_position);
- }
- else
- {
- std::tie(min_bound, max_bound) = get_activation_layer_test_bounds<int16_t>(act_info.activation(), fixed_point_position);
- }
- std::uniform_int_distribution<> distribution(min_bound, max_bound);
- library->fill(CLAccessor(src), distribution, 0);
- }
-
- // Compute function
- act_layer.run();
-
- if(in_place)
- {
- return src;
- }
- else
- {
- return dst;
- }
-}
-} // namespace
-
-#ifndef DOXYGEN_SKIP_THIS
-BOOST_AUTO_TEST_SUITE(CL)
-BOOST_AUTO_TEST_SUITE(ActivationLayer)
-
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
-BOOST_DATA_TEST_CASE(Configuration, boost::unit_test::data::make({ false, true }) * (SmallShapes() + LargeShapes()) * CNNDataTypes(), in_place, shape, dt)
-{
- // Set fixed point position data type allowed
- const int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0;
-
- // Create tensors
- CLTensor src = create_tensor<CLTensor>(shape, dt, 1, fixed_point_position);
- CLTensor dst = create_tensor<CLTensor>(shape, dt, 1, fixed_point_position);
-
- BOOST_TEST(src.info()->is_resizable());
- BOOST_TEST(dst.info()->is_resizable());
-
- // Create and configure function
- CLActivationLayer act_layer;
-
- if(in_place)
- {
- act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS));
- }
- else
- {
- act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS));
- }
-
- // Validate valid region
- const ValidRegion valid_region = shape_to_valid_region(shape);
- validate(src.info()->valid_region(), valid_region);
-
- if(!in_place)
- {
- validate(dst.info()->valid_region(), valid_region);
- }
-
- // Validate padding
- const int step = 16 / arm_compute::data_size_from_type(dt);
- const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding();
- validate(src.info()->padding(), padding);
-
- if(!in_place)
- {
- validate(dst.info()->padding(), padding);
- }
-}
-
-BOOST_AUTO_TEST_SUITE(Float)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * CNNFloatDataTypes() * ActivationFunctions() * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, dt, act_function, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- CLTensor dst = compute_activation_layer(in_place, shape, dt, act_info);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info);
-
- // Validate output
- validate(CLAccessor(dst), ref_dst, activation_layer_tolerance(act_function));
-}
-
-BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
-BOOST_DATA_TEST_CASE(RunLarge, boost::unit_test::data::make({ false, true }) * LargeShapes() * CNNFloatDataTypes() * ActivationFunctions() * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, dt, act_function, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- CLTensor dst = compute_activation_layer(in_place, shape, dt, act_info);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info);
-
- // Validate output
- validate(CLAccessor(dst), ref_dst, activation_layer_tolerance(act_function));
-}
-BOOST_AUTO_TEST_SUITE_END()
-
-/** @note We test for fixed point precision [3,5] because [1,2] and [6,7] ranges
- * cause overflowing issues in most of the transcendentals functions.
- */
-BOOST_AUTO_TEST_SUITE(Quantized)
-BOOST_AUTO_TEST_SUITE(QS8)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 6, 1) * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, act_function, fixed_point_position, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- CLTensor dst = compute_activation_layer(in_place, shape, DataType::QS8, act_info, fixed_point_position);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, DataType::QS8, act_info, fixed_point_position);
-
- // Validate output
- validate(CLAccessor(dst), ref_dst, activation_layer_tolerance(act_function, fixed_point_position));
-}
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE(QS16)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 14, 1) * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, act_function, fixed_point_position, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- CLTensor dst = compute_activation_layer(in_place, shape, DataType::QS16, act_info, fixed_point_position);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, DataType::QS16, act_info, fixed_point_position);
-
- // Validate output
- validate(CLAccessor(dst), ref_dst, activation_layer_tolerance(act_function, fixed_point_position));
-}
-BOOST_AUTO_TEST_SUITE_END()
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE_END()
-BOOST_AUTO_TEST_SUITE_END()
-#endif /* DOXYGEN_SKIP_THIS */ \ No newline at end of file
diff --git a/tests/validation/NEON/ActivationLayer.cpp b/tests/validation/NEON/ActivationLayer.cpp
deleted file mode 100644
index 5f1a2c6fb6..0000000000
--- a/tests/validation/NEON/ActivationLayer.cpp
+++ /dev/null
@@ -1,328 +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 "AssetsLibrary.h"
-#include "Globals.h"
-#include "NEON/Accessor.h"
-#include "PaddingCalculator.h"
-#include "TypePrinter.h"
-#include "Utils.h"
-#include "validation/Datasets.h"
-#include "validation/Helpers.h"
-#include "validation/Reference.h"
-#include "validation/Validation.h"
-
-#include "arm_compute/core/Helpers.h"
-#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h"
-#include "arm_compute/runtime/Tensor.h"
-#include "arm_compute/runtime/TensorAllocator.h"
-
-#include "boost_wrapper.h"
-
-#include <random>
-#include <string>
-#include <tuple>
-
-using namespace arm_compute;
-using namespace arm_compute::test;
-using namespace arm_compute::test::validation;
-
-namespace
-{
-/** Define tolerance of the activation layer
- *
- * @param[in] dt The data type used.
- * @param[in] activation The activation function used.
- * @param[in] fixed_point_position Number of bits for the fractional part..
- *
- * @return Tolerance depending on the activation function.
- */
-float activation_layer_tolerance(DataType dt, ActivationLayerInfo::ActivationFunction activation, int fixed_point_position = 0)
-{
- switch(activation)
- {
- case ActivationLayerInfo::ActivationFunction::LOGISTIC:
- case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
- case ActivationLayerInfo::ActivationFunction::SQRT:
- case ActivationLayerInfo::ActivationFunction::TANH:
- switch(dt)
- {
- case DataType::QS8:
- return 5.f;
- case DataType::QS16:
- return 11.f;
- case DataType::F16:
- return 0.01f;
- default:
- return 0.00001f;
- }
- break;
- default:
- return 0.f;
- }
-}
-
-/** Compute Neon activation layer function.
- *
- * @param[in] in_place Compute the activation layer in-place.
- * @param[in] shape Shape of the input and output tensors.
- * @param[in] dt Shape Data type of tensors.
- * @param[in] act_info Activation layer information.
- * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of fixed point numbers.
- *
- * @return Computed output tensor.
- */
-Tensor compute_activation_layer(bool in_place, const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0)
-{
- // Create tensors
- Tensor src = create_tensor<Tensor>(shape, dt, 1, fixed_point_position);
- Tensor dst = create_tensor<Tensor>(shape, dt, 1, fixed_point_position);
-
- // Create and configure function
- NEActivationLayer act_layer;
-
- if(in_place)
- {
- act_layer.configure(&src, nullptr, act_info);
- }
- else
- {
- act_layer.configure(&src, &dst, act_info);
- }
-
- // Allocate tensors
- src.allocator()->allocate();
- BOOST_TEST(!src.info()->is_resizable());
-
- if(!in_place)
- {
- dst.allocator()->allocate();
- BOOST_TEST(!dst.info()->is_resizable());
- }
- // Fill tensors
- switch(dt)
- {
- case DataType::QS8:
- {
- const std::pair<int8_t, int8_t> bounds = get_activation_layer_test_bounds<int8_t>(act_info.activation(), fixed_point_position);
- std::uniform_int_distribution<> distribution(bounds.first, bounds.second);
- library->fill(Accessor(src), distribution, 0);
- break;
- }
- case DataType::QS16:
- {
- const std::pair<int16_t, int16_t> bounds = get_activation_layer_test_bounds<int16_t>(act_info.activation(), fixed_point_position);
- std::uniform_int_distribution<> distribution(bounds.first, bounds.second);
- library->fill(Accessor(src), distribution, 0);
- break;
- }
-#ifdef ARM_COMPUTE_ENABLE_FP16
- case DataType::F16:
- {
- const std::pair<float16_t, float16_t> bounds = get_activation_layer_test_bounds<float16_t>(act_info.activation());
- std::uniform_real_distribution<> distribution(bounds.first, bounds.second);
- library->fill(Accessor(src), distribution, 0);
- break;
- }
-#endif /* ARM_COMPUTE_ENABLE_FP16 */
- case DataType::F32:
- {
- const std::pair<float, float> bounds = get_activation_layer_test_bounds<float>(act_info.activation());
- std::uniform_real_distribution<> distribution(bounds.first, bounds.second);
- library->fill(Accessor(src), distribution, 0);
- break;
- }
- default:
- {
- ARM_COMPUTE_ERROR("Not supported");
- break;
- }
- }
-
- // Compute function
- act_layer.run();
-
- if(in_place)
- {
- return src;
- }
- else
- {
- return dst;
- }
-}
-} // namespace
-
-#ifndef DOXYGEN_SKIP_THIS
-BOOST_AUTO_TEST_SUITE(NEON)
-BOOST_AUTO_TEST_SUITE(ActivationLayer)
-
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
-BOOST_DATA_TEST_CASE(Configuration, boost::unit_test::data::make({ false, true }) * (SmallShapes() + LargeShapes()) * CNNDataTypes(), in_place, shape, dt)
-{
- // Set fixed point position data type allowed
- const int fixed_point_position = (arm_compute::is_data_type_fixed_point(dt)) ? 3 : 0;
-
- // Create tensors
- Tensor src = create_tensor<Tensor>(shape, dt, 1, fixed_point_position);
- Tensor dst = create_tensor<Tensor>(shape, dt, 1, fixed_point_position);
-
- BOOST_TEST(src.info()->is_resizable());
- BOOST_TEST(dst.info()->is_resizable());
-
- // Create and configure function
- NEActivationLayer act_layer;
-
- if(in_place)
- {
- act_layer.configure(&src, nullptr, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS));
- }
- else
- {
- act_layer.configure(&src, &dst, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS));
- }
-
- // Validate valid region
- const ValidRegion valid_region = shape_to_valid_region(shape);
- validate(src.info()->valid_region(), valid_region);
-
- if(!in_place)
- {
- validate(dst.info()->valid_region(), valid_region);
- }
-
- // Validate padding
- const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding();
- validate(src.info()->padding(), padding);
-
- if(!in_place)
- {
- validate(dst.info()->padding(), padding);
- }
-}
-
-#ifdef ARM_COMPUTE_ENABLE_FP16
-BOOST_AUTO_TEST_SUITE(Float16)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * boost::unit_test::data::make(DataType::F16) * ActivationFunctions() * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, dt, act_function, alpha_beta)
-{
- // Create activation layer info
- const ActivationLayerInfo act_info(act_function, alpha_beta);
-
- // Compute function
- Tensor dst = compute_activation_layer(in_place, shape, dt, act_info);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info);
-
- // Validate output
- validate(Accessor(dst), ref_dst, activation_layer_tolerance(dt, act_function));
-}
-BOOST_AUTO_TEST_SUITE_END()
-#endif /* ARM_COMPUTE_ENABLE_FP16 */
-
-BOOST_AUTO_TEST_SUITE(Float)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * CNNFloatDataTypes() * ActivationFunctions() * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, dt, act_function, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- Tensor dst = compute_activation_layer(in_place, shape, dt, act_info);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info);
-
- // Validate output
- validate(Accessor(dst), ref_dst, activation_layer_tolerance(dt, act_function));
-}
-
-BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
-BOOST_DATA_TEST_CASE(RunLarge, boost::unit_test::data::make({ false, true }) * LargeShapes() * CNNFloatDataTypes() * ActivationFunctions() * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, dt, act_function, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- Tensor dst = compute_activation_layer(in_place, shape, dt, act_info);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, dt, act_info);
-
- // Validate output
- validate(Accessor(dst), ref_dst, activation_layer_tolerance(dt, act_function));
-}
-BOOST_AUTO_TEST_SUITE_END()
-
-/** @note We test for fixed point precision [3,5] because [1,2] and [6,7] ranges
- * cause overflowing issues in most of the transcendentals functions.
- */
-BOOST_AUTO_TEST_SUITE(Quantized)
-BOOST_AUTO_TEST_SUITE(QS8)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 6, 1) * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, act_function, fixed_point_position, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- Tensor dst = compute_activation_layer(in_place, shape, DataType::QS8, act_info, fixed_point_position);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, DataType::QS8, act_info, fixed_point_position);
-
- // Validate output
- validate(Accessor(dst), ref_dst, activation_layer_tolerance(DataType::QS8, act_function, fixed_point_position));
-}
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE(QS16)
-BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
-BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ false, true }) * SmallShapes() * ActivationFunctions() * boost::unit_test::data::xrange(3, 14, 1) * boost::unit_test::data::make({ 0.5f, 1.f }),
- in_place, shape, act_function, fixed_point_position, alpha_beta)
-{
- // Create activation layer info
- ActivationLayerInfo act_info(act_function, alpha_beta, alpha_beta);
-
- // Compute function
- Tensor dst = compute_activation_layer(in_place, shape, DataType::QS16, act_info, fixed_point_position);
-
- // Compute reference
- RawTensor ref_dst = Reference::compute_reference_activation_layer(shape, DataType::QS16, act_info, fixed_point_position);
-
- // Validate output
- validate(Accessor(dst), ref_dst, activation_layer_tolerance(DataType::QS16, act_function, fixed_point_position));
-}
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE_END()
-BOOST_AUTO_TEST_SUITE_END()
-#endif /* DOXYGEN_SKIP_THIS */
diff --git a/tests/validation/Reference.cpp b/tests/validation/Reference.cpp
index f9052f1dba..011fd091f2 100644
--- a/tests/validation/Reference.cpp
+++ b/tests/validation/Reference.cpp
@@ -453,56 +453,6 @@ RawTensor Reference::compute_reference_threshold(const TensorShape &shape, uint8
return ref_dst;
}
-RawTensor Reference::compute_reference_activation_layer(const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position)
-{
- // Create reference
- RawTensor ref_src(shape, dt, 1, fixed_point_position);
- RawTensor ref_dst(shape, dt, 1, fixed_point_position);
-
- // Fill tensors
- switch(dt)
- {
- case DataType::QS8:
- {
- const std::pair<int8_t, int8_t> bounds = get_activation_layer_test_bounds<int8_t>(act_info.activation(), fixed_point_position);
- std::uniform_int_distribution<> distribution(bounds.first, bounds.second);
- library->fill(ref_src, distribution, 0);
- break;
- }
- case DataType::QS16:
- {
- const std::pair<int16_t, int16_t> bounds = get_activation_layer_test_bounds<int16_t>(act_info.activation(), fixed_point_position);
- std::uniform_int_distribution<> distribution(bounds.first, bounds.second);
- library->fill(ref_src, distribution, 0);
- break;
- }
- case DataType::F16:
- {
- const std::pair<half_float::half, half_float::half> bounds = get_activation_layer_test_bounds<half_float::half>(act_info.activation());
- std::uniform_real_distribution<> distribution(bounds.first, bounds.second);
- library->fill(ref_src, distribution, 0);
- break;
- }
- case DataType::F32:
- {
- const std::pair<float, float> bounds = get_activation_layer_test_bounds<float>(act_info.activation());
- std::uniform_real_distribution<> distribution(bounds.first, bounds.second);
- library->fill(ref_src, distribution, 0);
- break;
- }
- default:
- {
- ARM_COMPUTE_ERROR("Not supported");
- break;
- }
- }
-
- // Compute reference
- ReferenceCPP::activation_layer(ref_src, ref_dst, act_info);
-
- return ref_dst;
-}
-
RawTensor Reference::compute_reference_batch_normalization_layer(const TensorShape &shape0, const TensorShape &shape1, DataType dt, float epsilon, int fixed_point_position)
{
// Create reference
diff --git a/tests/validation/Reference.h b/tests/validation/Reference.h
index eeaa55c739..42c62f8d6a 100644
--- a/tests/validation/Reference.h
+++ b/tests/validation/Reference.h
@@ -295,16 +295,6 @@ public:
* @return Computed raw tensor.
*/
static RawTensor compute_reference_threshold(const TensorShape &shape, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper);
- /** Compute reference activation layer.
- *
- * @param[in] shape Shape of the input and output tensors.
- * @param[in] dt Data type of the tensors.
- * @param[in] act_info Activation layer information.
- * @param[in] fixed_point_position (Optional)Number of bits for the fractional part of fixed point numbers.
- *
- * @return Computed raw tensor.
- */
- static RawTensor compute_reference_activation_layer(const TensorShape &shape, DataType dt, ActivationLayerInfo act_info, int fixed_point_position = 0);
/** Compute reference batch normalization layer.
*
* @param[in] shape0 Shape of the input and output tensors.
diff --git a/tests/validation/ReferenceCPP.cpp b/tests/validation/ReferenceCPP.cpp
index 81ec60d5b9..117fd5bebb 100644
--- a/tests/validation/ReferenceCPP.cpp
+++ b/tests/validation/ReferenceCPP.cpp
@@ -283,14 +283,6 @@ void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t thres
tensor_operations::threshold(s, d, threshold, false_value, true_value, type, upper);
}
-// Activation layer
-void ReferenceCPP::activation_layer(const RawTensor &input, RawTensor &output, ActivationLayerInfo act_info)
-{
- const TensorVariant s = TensorFactory::get_tensor(input);
- TensorVariant d = TensorFactory::get_tensor(output);
- boost::apply_visitor(tensor_visitors::activation_layer_visitor(s, act_info), d);
-}
-
// Batch Normalization Layer
void ReferenceCPP::batch_normalization_layer(const RawTensor &src, RawTensor &dst, const RawTensor &mean, const RawTensor &var, const RawTensor &beta, const RawTensor &gamma, float epsilon,
int fixed_point_position)
diff --git a/tests/validation/ReferenceCPP.h b/tests/validation/ReferenceCPP.h
index 97e573cfa2..0d1bea48bd 100644
--- a/tests/validation/ReferenceCPP.h
+++ b/tests/validation/ReferenceCPP.h
@@ -253,13 +253,6 @@ public:
* @param[in] upper Upper threshold. Only used when the thresholding type is RANGE.
*/
static void threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper);
- /** Activation layer of @p src base on information from @p act_info.
- *
- * @param[in] input Input tensor.
- * @param[in] output Second tensor.
- * @param[out] act_info Activation layer information.
- */
- static void activation_layer(const RawTensor &input, RawTensor &output, ActivationLayerInfo act_info);
/** Batch Normalization of @p src based on the information from @p norm_info.
*
* @param[in] src Input tensor.
diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h
index b472e3d5cf..db145c19ad 100644
--- a/tests/validation/TensorOperations.h
+++ b/tests/validation/TensorOperations.h
@@ -935,109 +935,6 @@ void threshold(const Tensor<T> &in, Tensor<T> &out, uint8_t threshold, uint8_t f
}
}
-// Activation Layer for floating point type
-template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type * = nullptr>
-void activation_layer(const Tensor<T> &in, Tensor<T> &out, ActivationLayerInfo act_info)
-{
- const T a = static_cast<T>(act_info.a());
- const T b = static_cast<T>(act_info.b());
-
- for(int i = 0; i < in.num_elements(); ++i)
- {
- T x = in[i];
- switch(act_info.activation())
- {
- case ActivationLayerInfo::ActivationFunction::ABS:
- out[i] = std::abs(x);
- break;
- case ActivationLayerInfo::ActivationFunction::LINEAR:
- out[i] = a * x + b;
- break;
- case ActivationLayerInfo::ActivationFunction::LOGISTIC:
- out[i] = static_cast<T>(1) / (static_cast<T>(1) + std::exp(-x));
- break;
- case ActivationLayerInfo::ActivationFunction::RELU:
- out[i] = std::max(static_cast<T>(0), x);
- break;
- case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
- out[i] = std::min<T>(a, std::max(static_cast<T>(0), x));
- break;
- case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
- out[i] = (x > 0) ? x : a * x;
- break;
- case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
- out[i] = std::log(static_cast<T>(1) + std::exp(x));
- break;
- case ActivationLayerInfo::ActivationFunction::SQRT:
- out[i] = std::sqrt(x);
- break;
- case ActivationLayerInfo::ActivationFunction::SQUARE:
- out[i] = x * x;
- break;
- case ActivationLayerInfo::ActivationFunction::TANH:
- out[i] = a * std::tanh(b * x);
- break;
- default:
- ARM_COMPUTE_ERROR("Activation function not recognised");
- break;
- }
- }
-}
-
-// Activation Layer for fixed point type
-template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type * = nullptr>
-void activation_layer(const Tensor<T> &in, Tensor<T> &out, ActivationLayerInfo act_info)
-{
- using namespace fixed_point_arithmetic;
- int fixed_point_position = in.fixed_point_position();
- ActivationLayerInfo::ActivationFunction act_func = act_info.activation();
- const fixed_point<T> a(act_info.a(), fixed_point_position);
- const fixed_point<T> b(act_info.b(), fixed_point_position);
- const fixed_point<T> const_0(0, fixed_point_position);
- const fixed_point<T> const_1(1, fixed_point_position);
-
- for(int i = 0; i < in.num_elements(); ++i)
- {
- fixed_point<T> x(in[i], fixed_point_position, true);
- switch(act_func)
- {
- case ActivationLayerInfo::ActivationFunction::ABS:
- out[i] = abs(x).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::LINEAR:
- out[i] = add(b, mul(a, x)).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::LOGISTIC:
- out[i] = (const_1 / (const_1 + exp(-x))).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::RELU:
- out[i] = max(const_0, x).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU:
- out[i] = min(a, max(const_0, x)).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::LEAKY_RELU:
- out[i] = (x > const_0) ? x.raw() : mul(a, x).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
- out[i] = log(const_1 + exp(x)).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::SQRT:
- out[i] = (const_1 / inv_sqrt(x)).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::SQUARE:
- out[i] = mul(x, x).raw();
- break;
- case ActivationLayerInfo::ActivationFunction::TANH:
- out[i] = mul(a, tanh(mul(b, x))).raw();
- break;
- default:
- ARM_COMPUTE_ERROR("Activation function not recognised");
- break;
- }
- }
-}
-
// Batch Normalization Layer for fixed point type
template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type * = nullptr>
void batch_normalization_layer(const Tensor<T> &in, Tensor<T> &out, const Tensor<T> &mean, const Tensor<T> &var, const Tensor<T> &beta, const Tensor<T> &gamma, float epsilon, int fixed_point_position)
diff --git a/tests/validation/TensorVisitors.h b/tests/validation/TensorVisitors.h
index 44ae6f13e8..365aac7758 100644
--- a/tests/validation/TensorVisitors.h
+++ b/tests/validation/TensorVisitors.h
@@ -228,26 +228,6 @@ private:
template struct arm_compute::test::validation::tensor_visitors::table_lookup<uint8_t>;
template struct arm_compute::test::validation::tensor_visitors::table_lookup<int16_t>;
-// Activation layer visitor
-struct activation_layer_visitor : public boost::static_visitor<>
-{
-public:
- explicit activation_layer_visitor(const TensorVariant &in, ActivationLayerInfo act_info)
- : _in(in), _act_info(act_info)
- {
- }
-
- template <typename T>
- void operator()(Tensor<T> &out) const
- {
- const auto &in = boost::get<Tensor<T>>(_in);
- tensor_operations::activation_layer(in, out, _act_info);
- }
-
-private:
- const TensorVariant &_in;
- const ActivationLayerInfo _act_info;
-};
// Batch Normalization Layer visitor
struct batch_normalization_layer_visitor : public boost::static_visitor<>
{