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_new/CL/ActivationLayer.cpp | 247 ------ tests/validation_new/CL/BitwiseAnd.cpp | 94 -- tests/validation_new/CL/BitwiseNot.cpp | 90 -- tests/validation_new/CL/BitwiseOr.cpp | 94 -- tests/validation_new/CL/BitwiseXor.cpp | 94 -- tests/validation_new/CL/ConvolutionLayer.cpp | 186 ---- tests/validation_new/CL/DepthConcatenateLayer.cpp | 123 --- tests/validation_new/CL/DepthwiseConvolution.cpp | 69 -- .../CL/DepthwiseSeparableConvolutionLayer.cpp | 64 -- tests/validation_new/CL/DirectConvolutionLayer.cpp | 129 --- tests/validation_new/CL/Floor.cpp | 66 -- tests/validation_new/CL/FullyConnectedLayer.cpp | 195 ---- tests/validation_new/CL/GEMM.cpp | 167 ---- tests/validation_new/CL/L2Normalize.cpp | 78 -- tests/validation_new/CL/MeanStdDev.cpp | 97 -- tests/validation_new/CL/NormalizationLayer.cpp | 141 --- tests/validation_new/CL/PoolingLayer.cpp | 142 --- tests/validation_new/CL/ReductionOperation.cpp | 78 -- tests/validation_new/CL/Scale.cpp | 129 --- tests/validation_new/CL/SoftmaxLayer.cpp | 168 ---- tests/validation_new/CPP/ActivationLayer.cpp | 158 ---- tests/validation_new/CPP/ActivationLayer.h | 47 - tests/validation_new/CPP/BitwiseAnd.cpp | 51 -- tests/validation_new/CPP/BitwiseAnd.h | 43 - tests/validation_new/CPP/BitwiseNot.cpp | 51 -- tests/validation_new/CPP/BitwiseNot.h | 43 - tests/validation_new/CPP/BitwiseOr.cpp | 51 -- tests/validation_new/CPP/BitwiseOr.h | 43 - tests/validation_new/CPP/BitwiseXor.cpp | 51 -- tests/validation_new/CPP/BitwiseXor.h | 43 - tests/validation_new/CPP/ConvolutionLayer.cpp | 205 ----- tests/validation_new/CPP/ConvolutionLayer.h | 44 - tests/validation_new/CPP/DepthConcatenateLayer.cpp | 104 --- tests/validation_new/CPP/DepthConcatenateLayer.h | 45 - tests/validation_new/CPP/DepthwiseConvolution.cpp | 103 --- tests/validation_new/CPP/DepthwiseConvolution.h | 44 - .../CPP/DepthwiseSeparableConvolutionLayer.cpp | 60 -- .../CPP/DepthwiseSeparableConvolutionLayer.h | 46 - tests/validation_new/CPP/DequantizationLayer.cpp | 55 -- tests/validation_new/CPP/DequantizationLayer.h | 44 - tests/validation_new/CPP/Floor.cpp | 57 -- tests/validation_new/CPP/Floor.h | 44 - tests/validation_new/CPP/FullyConnectedLayer.cpp | 133 --- tests/validation_new/CPP/FullyConnectedLayer.h | 44 - tests/validation_new/CPP/GEMM.cpp | 122 --- tests/validation_new/CPP/GEMM.h | 47 - tests/validation_new/CPP/L2Normalize.cpp | 88 -- tests/validation_new/CPP/L2Normalize.h | 44 - tests/validation_new/CPP/MeanStdDev.cpp | 57 -- tests/validation_new/CPP/MeanStdDev.h | 43 - tests/validation_new/CPP/NormalizationLayer.cpp | 275 ------ tests/validation_new/CPP/NormalizationLayer.h | 47 - tests/validation_new/CPP/PoolingLayer.cpp | 243 ----- tests/validation_new/CPP/PoolingLayer.h | 47 - tests/validation_new/CPP/QuantizationLayer.cpp | 85 -- tests/validation_new/CPP/QuantizationLayer.h | 44 - tests/validation_new/CPP/ReductionOperation.cpp | 93 -- tests/validation_new/CPP/ReductionOperation.h | 44 - tests/validation_new/CPP/Scale.cpp | 166 ---- tests/validation_new/CPP/Scale.h | 43 - tests/validation_new/CPP/SoftmaxLayer.cpp | 122 --- tests/validation_new/CPP/SoftmaxLayer.h | 47 - tests/validation_new/CPP/Utils.cpp | 93 -- tests/validation_new/CPP/Utils.h | 54 -- tests/validation_new/FixedPoint.h | 984 --------------------- tests/validation_new/Helpers.cpp | 57 -- tests/validation_new/Helpers.h | 142 --- tests/validation_new/NEON/ActivationLayer.cpp | 230 ----- tests/validation_new/NEON/BitwiseAnd.cpp | 94 -- tests/validation_new/NEON/BitwiseNot.cpp | 90 -- tests/validation_new/NEON/BitwiseOr.cpp | 94 -- tests/validation_new/NEON/BitwiseXor.cpp | 94 -- tests/validation_new/NEON/ConvolutionLayer.cpp | 192 ---- .../validation_new/NEON/DepthConcatenateLayer.cpp | 125 --- tests/validation_new/NEON/DequantizationLayer.cpp | 100 --- .../validation_new/NEON/DirectConvolutionLayer.cpp | 149 ---- tests/validation_new/NEON/Floor.cpp | 66 -- tests/validation_new/NEON/FullyConnectedLayer.cpp | 211 ----- tests/validation_new/NEON/GEMM.cpp | 170 ---- tests/validation_new/NEON/L2Normalize.cpp | 75 -- tests/validation_new/NEON/MeanStdDev.cpp | 93 -- tests/validation_new/NEON/NormalizationLayer.cpp | 144 --- tests/validation_new/NEON/PoolingLayer.cpp | 148 ---- tests/validation_new/NEON/QuantizationLayer.cpp | 98 -- tests/validation_new/NEON/ReductionOperation.cpp | 75 -- tests/validation_new/NEON/Scale.cpp | 127 --- tests/validation_new/NEON/SoftmaxLayer.cpp | 175 ---- tests/validation_new/Validation.cpp | 307 ------- tests/validation_new/Validation.h | 351 -------- .../fixtures/ActivationLayerFixture.h | 157 ---- tests/validation_new/fixtures/BitwiseAndFixture.h | 113 --- tests/validation_new/fixtures/BitwiseNotFixture.h | 106 --- tests/validation_new/fixtures/BitwiseOrFixture.h | 113 --- tests/validation_new/fixtures/BitwiseXorFixture.h | 113 --- .../fixtures/ConvolutionLayerFixture.h | 152 ---- .../fixtures/DepthConcatenateLayerFixture.h | 177 ---- .../fixtures/DepthwiseConvolutionFixture.h | 120 --- .../DepthwiseSeparableConvolutionLayerFixture.h | 139 --- .../fixtures/DequantizationLayerFixture.h | 147 --- .../fixtures/DirectConvolutionLayerFixture.h | 86 -- tests/validation_new/fixtures/FloorFixture.h | 107 --- .../fixtures/FullyConnectedLayerFixture.h | 250 ------ tests/validation_new/fixtures/GEMMFixture.h | 152 ---- tests/validation_new/fixtures/L2NormalizeFixture.h | 107 --- tests/validation_new/fixtures/MeanStdDevFixture.h | 102 --- .../fixtures/NormalizationLayerFixture.h | 133 --- .../validation_new/fixtures/PoolingLayerFixture.h | 134 --- .../fixtures/QuantizationLayerFixture.h | 120 --- .../fixtures/ReductionOperationFixture.h | 116 --- tests/validation_new/fixtures/ScaleFixture.h | 127 --- .../validation_new/fixtures/SoftmaxLayerFixture.h | 133 --- tests/validation_new/half.h | 38 - 112 files changed, 13197 deletions(-) delete mode 100644 tests/validation_new/CL/ActivationLayer.cpp delete mode 100644 tests/validation_new/CL/BitwiseAnd.cpp delete mode 100644 tests/validation_new/CL/BitwiseNot.cpp delete mode 100644 tests/validation_new/CL/BitwiseOr.cpp delete mode 100644 tests/validation_new/CL/BitwiseXor.cpp delete mode 100644 tests/validation_new/CL/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/CL/DepthwiseConvolution.cpp delete mode 100644 tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/DirectConvolutionLayer.cpp delete mode 100644 tests/validation_new/CL/Floor.cpp delete mode 100644 tests/validation_new/CL/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/CL/GEMM.cpp delete mode 100644 tests/validation_new/CL/L2Normalize.cpp delete mode 100644 tests/validation_new/CL/MeanStdDev.cpp delete mode 100644 tests/validation_new/CL/NormalizationLayer.cpp delete mode 100644 tests/validation_new/CL/PoolingLayer.cpp delete mode 100644 tests/validation_new/CL/ReductionOperation.cpp delete mode 100644 tests/validation_new/CL/Scale.cpp delete mode 100644 tests/validation_new/CL/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/CPP/ActivationLayer.cpp delete mode 100644 tests/validation_new/CPP/ActivationLayer.h delete mode 100644 tests/validation_new/CPP/BitwiseAnd.cpp delete mode 100644 tests/validation_new/CPP/BitwiseAnd.h delete mode 100644 tests/validation_new/CPP/BitwiseNot.cpp delete mode 100644 tests/validation_new/CPP/BitwiseNot.h delete mode 100644 tests/validation_new/CPP/BitwiseOr.cpp delete mode 100644 tests/validation_new/CPP/BitwiseOr.h delete mode 100644 tests/validation_new/CPP/BitwiseXor.cpp delete mode 100644 tests/validation_new/CPP/BitwiseXor.h delete mode 100644 tests/validation_new/CPP/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/CPP/ConvolutionLayer.h delete mode 100644 tests/validation_new/CPP/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/CPP/DepthConcatenateLayer.h delete mode 100644 tests/validation_new/CPP/DepthwiseConvolution.cpp delete mode 100644 tests/validation_new/CPP/DepthwiseConvolution.h delete mode 100644 tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp delete mode 100644 tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h delete mode 100644 tests/validation_new/CPP/DequantizationLayer.cpp delete mode 100644 tests/validation_new/CPP/DequantizationLayer.h delete mode 100644 tests/validation_new/CPP/Floor.cpp delete mode 100644 tests/validation_new/CPP/Floor.h delete mode 100644 tests/validation_new/CPP/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/CPP/FullyConnectedLayer.h delete mode 100644 tests/validation_new/CPP/GEMM.cpp delete mode 100644 tests/validation_new/CPP/GEMM.h delete mode 100644 tests/validation_new/CPP/L2Normalize.cpp delete mode 100644 tests/validation_new/CPP/L2Normalize.h delete mode 100644 tests/validation_new/CPP/MeanStdDev.cpp delete mode 100644 tests/validation_new/CPP/MeanStdDev.h delete mode 100644 tests/validation_new/CPP/NormalizationLayer.cpp delete mode 100644 tests/validation_new/CPP/NormalizationLayer.h delete mode 100644 tests/validation_new/CPP/PoolingLayer.cpp delete mode 100644 tests/validation_new/CPP/PoolingLayer.h delete mode 100644 tests/validation_new/CPP/QuantizationLayer.cpp delete mode 100644 tests/validation_new/CPP/QuantizationLayer.h delete mode 100644 tests/validation_new/CPP/ReductionOperation.cpp delete mode 100644 tests/validation_new/CPP/ReductionOperation.h delete mode 100644 tests/validation_new/CPP/Scale.cpp delete mode 100644 tests/validation_new/CPP/Scale.h delete mode 100644 tests/validation_new/CPP/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/CPP/SoftmaxLayer.h delete mode 100644 tests/validation_new/CPP/Utils.cpp delete mode 100644 tests/validation_new/CPP/Utils.h delete mode 100644 tests/validation_new/FixedPoint.h delete mode 100644 tests/validation_new/Helpers.cpp delete mode 100644 tests/validation_new/Helpers.h delete mode 100644 tests/validation_new/NEON/ActivationLayer.cpp delete mode 100644 tests/validation_new/NEON/BitwiseAnd.cpp delete mode 100644 tests/validation_new/NEON/BitwiseNot.cpp delete mode 100644 tests/validation_new/NEON/BitwiseOr.cpp delete mode 100644 tests/validation_new/NEON/BitwiseXor.cpp delete mode 100644 tests/validation_new/NEON/ConvolutionLayer.cpp delete mode 100644 tests/validation_new/NEON/DepthConcatenateLayer.cpp delete mode 100644 tests/validation_new/NEON/DequantizationLayer.cpp delete mode 100644 tests/validation_new/NEON/DirectConvolutionLayer.cpp delete mode 100644 tests/validation_new/NEON/Floor.cpp delete mode 100644 tests/validation_new/NEON/FullyConnectedLayer.cpp delete mode 100644 tests/validation_new/NEON/GEMM.cpp delete mode 100644 tests/validation_new/NEON/L2Normalize.cpp delete mode 100644 tests/validation_new/NEON/MeanStdDev.cpp delete mode 100644 tests/validation_new/NEON/NormalizationLayer.cpp delete mode 100644 tests/validation_new/NEON/PoolingLayer.cpp delete mode 100644 tests/validation_new/NEON/QuantizationLayer.cpp delete mode 100644 tests/validation_new/NEON/ReductionOperation.cpp delete mode 100644 tests/validation_new/NEON/Scale.cpp delete mode 100644 tests/validation_new/NEON/SoftmaxLayer.cpp delete mode 100644 tests/validation_new/Validation.cpp delete mode 100644 tests/validation_new/Validation.h delete mode 100644 tests/validation_new/fixtures/ActivationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseAndFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseNotFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseOrFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseXorFixture.h delete mode 100644 tests/validation_new/fixtures/ConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthConcatenateLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseConvolutionFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DequantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DirectConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/FloorFixture.h delete mode 100644 tests/validation_new/fixtures/FullyConnectedLayerFixture.h delete mode 100644 tests/validation_new/fixtures/GEMMFixture.h delete mode 100644 tests/validation_new/fixtures/L2NormalizeFixture.h delete mode 100644 tests/validation_new/fixtures/MeanStdDevFixture.h delete mode 100644 tests/validation_new/fixtures/NormalizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/PoolingLayerFixture.h delete mode 100644 tests/validation_new/fixtures/QuantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/ReductionOperationFixture.h delete mode 100644 tests/validation_new/fixtures/ScaleFixture.h delete mode 100644 tests/validation_new/fixtures/SoftmaxLayerFixture.h delete mode 100644 tests/validation_new/half.h (limited to 'tests/validation_new') diff --git a/tests/validation_new/CL/ActivationLayer.cpp b/tests/validation_new/CL/ActivationLayer.cpp deleted file mode 100644 index c8fddc7db6..0000000000 --- a/tests/validation_new/CL/ActivationLayer.cpp +++ /dev/null @@ -1,247 +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 "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 "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ActivationFunctionsDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ActivationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Define tolerance of the activation layer. - * - * @param[in] activation The activation function used. - * @param[in] data_type Data type. - * - * @return Tolerance depending on the activation function. - */ -AbsoluteTolerance tolerance(ActivationLayerInfo::ActivationFunction activation, DataType data_type) -{ - constexpr float epsilon = 1e-6f; - - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LINEAR: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.2f : epsilon); - case ActivationLayerInfo::ActivationFunction::SQUARE: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.1f : epsilon); - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : epsilon); - } - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - return AbsoluteTolerance(data_type == DataType::F16 ? 0.00001f : epsilon); - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::SQRT: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.01f : 0.00001f); - } - case ActivationLayerInfo::ActivationFunction::TANH: - if(is_data_type_fixed_point(data_type)) - { - return AbsoluteTolerance(5.f); - } - else - { - return AbsoluteTolerance(data_type == DataType::F16 ? 0.001f : 0.00001f); - } - default: - return AbsoluteTolerance(epsilon); - } -} - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -/** Input data sets. */ -const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ActivationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), - shape, data_type, in_place) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // 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(data_type); - const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); - validate(src.info()->padding(), padding); - - if(!in_place) - { - validate(dst.info()->padding(), padding); - } -} - -template -using CLActivationLayerFixture = ActivationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause -// overflowing issues in most of the transcendentals functions. -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance(_function, _data_type)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseAnd.cpp b/tests/validation_new/CL/BitwiseAnd.cpp deleted file mode 100644 index af40812b2a..0000000000 --- a/tests/validation_new/CL/BitwiseAnd.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseAnd.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseAndFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseAnd) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseAnd bitwise_and; - bitwise_and.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseAndFixture = BitwiseAndValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseNot.cpp b/tests/validation_new/CL/BitwiseNot.cpp deleted file mode 100644 index e95619f481..0000000000 --- a/tests/validation_new/CL/BitwiseNot.cpp +++ /dev/null @@ -1,90 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseNot.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseNotFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseNot) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseNot bitwise_not; - bitwise_not.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseNotFixture = BitwiseNotValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseOr.cpp b/tests/validation_new/CL/BitwiseOr.cpp deleted file mode 100644 index 15964eecc3..0000000000 --- a/tests/validation_new/CL/BitwiseOr.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseOr.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseOrFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseOr) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseOr bitwise_or; - bitwise_or.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseOrFixture = BitwiseOrValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/BitwiseXor.cpp b/tests/validation_new/CL/BitwiseXor.cpp deleted file mode 100644 index 8e8852209b..0000000000 --- a/tests/validation_new/CL/BitwiseXor.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLBitwiseXor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseXorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(BitwiseXor) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src1 = create_tensor(shape, data_type); - CLTensor src2 = create_tensor(shape, data_type); - CLTensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLBitwiseXor bitwise_xor; - bitwise_xor.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLBitwiseXorFixture = BitwiseXorValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/ConvolutionLayer.cpp b/tests/validation_new/CL/ConvolutionLayer.cpp deleted file mode 100644 index 9703e0bcba..0000000000 --- a/tests/validation_new/CL/ConvolutionLayer.cpp +++ /dev/null @@ -1,186 +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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#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/CLConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeConvolutionLayerDataset.h" -#include "tests/datasets_new/SmallConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ConvolutionLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), - input_shape, weights_shape, bias_shape, output_shape, info, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLConvolutionLayer conv; - conv.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(input_shape); - const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); - const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); - const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); - - validate(src.info()->valid_region(), src_valid_region); - validate(weights.info()->valid_region(), weights_valid_region); - validate(bias.info()->valid_region(), bias_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - //TODO(COMPMID-415) Need to validate padding? -} - -template -using CLConvolutionLayerFixture = ConvolutionValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) -FIXTURE_DATA_TEST_CASE(RunSmall, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthConcatenateLayer.cpp b/tests/validation_new/CL/DepthConcatenateLayer.cpp deleted file mode 100644 index ff64e2340b..0000000000 --- a/tests/validation_new/CL/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,123 +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 "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/CLDepthConcatenate.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthConcatenateLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(DepthConcatenateLayer) - -//TODO(COMPMID-415): Add configuration test? - -template -using CLDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthwiseConvolution.cpp b/tests/validation_new/CL/DepthwiseConvolution.cpp deleted file mode 100644 index 3fda275715..0000000000 --- a/tests/validation_new/CL/DepthwiseConvolution.cpp +++ /dev/null @@ -1,69 +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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#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/CLDepthwiseConvolution.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeDepthwiseConvolutionDataset.h" -#include "tests/datasets_new/SmallDepthwiseConvolutionDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthwiseConvolutionFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DepthwiseConvolution) - -template -using CLDepthwiseConvolutionFixture = DepthwiseConvolutionValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseConvolutionFixture, framework::DatasetMode::PRECOMMIT, datasets::SmallDepthwiseConvolutionDataset()) -{ - validate(CLAccessor(_target), _reference, tolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, CLDepthwiseConvolutionFixture, framework::DatasetMode::NIGHTLY, datasets::LargeDepthwiseConvolutionDataset()) -{ - validate(CLAccessor(_target), _reference, tolerance_f32); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp deleted file mode 100644 index e577f5af04..0000000000 --- a/tests/validation_new/CL/DepthwiseSeparableConvolutionLayer.cpp +++ /dev/null @@ -1,64 +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 CONCLCTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#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/CLDepthwiseSeparableConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/MobileNetDepthwiseSeparableConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DepthwiseSeparableConvolutionLayer) - -// Configuration test to do - -template -using CLDepthwiseSeparableConvolutionLayerFixture = DepthwiseSeparableConvolutionValidationFixture; -FIXTURE_DATA_TEST_CASE(RunSmall, CLDepthwiseSeparableConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, datasets::MobileNetDepthwiseSeparableConvolutionLayerDataset()) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/DirectConvolutionLayer.cpp b/tests/validation_new/CL/DirectConvolutionLayer.cpp deleted file mode 100644 index 1c698ace0f..0000000000 --- a/tests/validation_new/CL/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,129 +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 "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/CLDirectConvolutionLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DirectConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_fp16(0.1f); /**< Tolerance for floating point tests */ -constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ - -constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance for fixed point tests */ -constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance for fixed point tests */ - -/** Direct convolution data set. */ -const auto data_quantized = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", { 3 })))), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -const auto data = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", { 3, 5 })))), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(DirectConvolutionLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using CLDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fp16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fp32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS8)), - framework::dataset::make("FractionalBits", 2, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(Run, CLDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_quantized, framework::dataset::make("DataType", DataType::QS16)), - framework::dataset::make("FractionalBits", 2, 15))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/Floor.cpp b/tests/validation_new/CL/Floor.cpp deleted file mode 100644 index 461a914be9..0000000000 --- a/tests/validation_new/CL/Floor.cpp +++ /dev/null @@ -1,66 +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 "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/CLFloor.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(CL) -TEST_SUITE(Floor) - -template -using CLFloorFixture = FloorValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/FullyConnectedLayer.cpp b/tests/validation_new/CL/FullyConnectedLayer.cpp deleted file mode 100644 index e43997c47b..0000000000 --- a/tests/validation_new/CL/FullyConnectedLayer.cpp +++ /dev/null @@ -1,195 +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 "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/CLFullyConnectedLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/FullyConnectedLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FullyConnectedLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -constexpr AbsoluteTolerance tolerance_f16(0.4f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(1.f); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(FullyConnectedLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), - FullyConnectedParameters), - CNNDataTypes), - src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - TensorShape ws(weights_shape); - - // Transpose weights if not done in the function - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = ws.x(); - ws.set(0, ws.y()); - ws.set(1, shape_x); - } - - // Create tensors - CLTensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); - CLTensor weights = create_tensor(ws, data_type, 1, fixed_point_position); - CLTensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - CLFullyConnectedLayer fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using CLFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/GEMM.cpp b/tests/validation_new/CL/GEMM.cpp deleted file mode 100644 index 7da5da3ed9..0000000000 --- a/tests/validation_new/CL/GEMM.cpp +++ /dev/null @@ -1,167 +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 "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/CLGEMM.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeGEMMDataset.h" -#include "tests/datasets_new/SmallGEMMDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/GEMMFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_f16(0.1f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(GEMM) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), - shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); - CLTensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); - CLTensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLGEMM gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - //TODO(COMPMID-415): Validate valid region -} - -template -using CLGEMMFixture = GEMMValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLGEMMFixedPointFixture = GEMMValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/L2Normalize.cpp b/tests/validation_new/CL/L2Normalize.cpp deleted file mode 100644 index d7882a842a..0000000000 --- a/tests/validation_new/CL/L2Normalize.cpp +++ /dev/null @@ -1,78 +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 "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/CLL2Normalize.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/L2NormalizeFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.00001f); - -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(L2Normalize) - -template -using CLL2NormalizeFixture = L2NormalizeValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLL2NormalizeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/MeanStdDev.cpp b/tests/validation_new/CL/MeanStdDev.cpp deleted file mode 100644 index 494e1001bc..0000000000 --- a/tests/validation_new/CL/MeanStdDev.cpp +++ /dev/null @@ -1,97 +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 "arm_compute/runtime/CL/functions/CLMeanStdDev.h" -#include "framework/Macros.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/MeanStdDevFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr RelativeTolerance tolerance_rel_high_error(0.05f); -constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(MeanStdDev) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - CLTensor src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.f; - float std_dev = 0.f; - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create configure function - CLMeanStdDev mean_std_dev_image; - mean_std_dev_image.configure(&src, &mean, &std_dev); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); -} - -template -using CLMeanStdDevFixture = MeanStdDevValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first, tolerance_rel_low_error); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/NormalizationLayer.cpp b/tests/validation_new/CL/NormalizationLayer.cpp deleted file mode 100644 index 37e77f3632..0000000000 --- a/tests/validation_new/CL/NormalizationLayer.cpp +++ /dev/null @@ -1,141 +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 "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/CLNormalizationLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/NormalizationTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/NormalizationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f16(0.01f); -constexpr AbsoluteTolerance tolerance_f32(0.00001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_qs8(2); -constexpr AbsoluteTolerance tolerance_qs16(2); - -/** Input data set. */ -const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("NormType", { NormType::IN_MAP_1D, NormType::CROSS_MAP })), - framework::dataset::make("NormalizationSize", 3, 9, 2)), - framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(NormalizationLayer) - -//TODO(COMPMID-415): Missing configuration? - -template -using CLNormalizationLayerFixture = NormalizationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLNormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLNormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/PoolingLayer.cpp b/tests/validation_new/CL/PoolingLayer.cpp deleted file mode 100644 index d38a3b2c6a..0000000000 --- a/tests/validation_new/CL/PoolingLayer.cpp +++ /dev/null @@ -1,142 +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 "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/CLPoolingLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/PoolingTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/PoolingLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Input data set for float data types */ -const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -/** Input data set for quantized data types */ -const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -constexpr AbsoluteTolerance tolerance_qs8(3); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -constexpr AbsoluteTolerance tolerance_qs16(6); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(PoolingLayer) - -template -using CLPoolingLayerFixture = PoolingLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 4))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 4))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 12))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 12))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/ReductionOperation.cpp b/tests/validation_new/CL/ReductionOperation.cpp deleted file mode 100644 index af49d736ab..0000000000 --- a/tests/validation_new/CL/ReductionOperation.cpp +++ /dev/null @@ -1,78 +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 "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/CLReductionOperation.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ReductionOperationDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ReductionOperationFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(ReductionOperation) - -template -using CLReductionOperationFixture = ReductionOperationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLReductionOperationFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLReductionOperationFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/Scale.cpp b/tests/validation_new/CL/Scale.cpp deleted file mode 100644 index e28555ac21..0000000000 --- a/tests/validation_new/CL/Scale.cpp +++ /dev/null @@ -1,129 +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 "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLScale.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/BorderModeDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ScaleFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance */ -constexpr AbsoluteTolerance tolerance(1); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(Scale) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - shape, data_type, policy, border_mode) -{ - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 2); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - std::uniform_int_distribution distribution_u8(0, 255); - uint8_t constant_border_value = distribution_u8(generator); - - // Create tensors - CLTensor src = create_tensor(shape, data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - CLTensor dst = create_tensor(shape_scaled, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLScale clscale; - clscale.configure(&src, &dst, policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); - - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape_scaled.x(), 4); - calculator.set_border_mode(border_mode); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -template -using CLScaleFixture = ScaleValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, CLScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", -{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), -datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(CLAccessor(_target), _reference, valid_region, tolerance); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", -{ InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), -datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(CLAccessor(_target), _reference, valid_region, tolerance); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CL/SoftmaxLayer.cpp b/tests/validation_new/CL/SoftmaxLayer.cpp deleted file mode 100644 index d13236a2f9..0000000000 --- a/tests/validation_new/CL/SoftmaxLayer.cpp +++ /dev/null @@ -1,168 +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 "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/CLSoftmaxLayer.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/SoftmaxLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f16(0.002f); -constexpr AbsoluteTolerance tolerance_f32(0.000001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(2); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ - DataType::F16, - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(SoftmaxLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - CLTensor src = create_tensor(shape, data_type, 1, fixed_point_position); - CLTensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - CLSoftmaxLayer smx_layer; - smx_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using CLSoftmaxLayerFixture = SoftmaxValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using CLSoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, CLSoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(CLAccessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ActivationLayer.cpp b/tests/validation_new/CPP/ActivationLayer.cpp deleted file mode 100644 index 052c3aa566..0000000000 --- a/tests/validation_new/CPP/ActivationLayer.cpp +++ /dev/null @@ -1,158 +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 "ActivationLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const T a(info.a()); - const T b(info.b()); - - for(int i = 0; i < src.num_elements(); ++i) - { - T x = src[i]; - - switch(info.activation()) - { - case ActivationLayerInfo::ActivationFunction::ABS: - dst[i] = std::abs(x); - break; - case ActivationLayerInfo::ActivationFunction::LINEAR: - dst[i] = a * x + b; - break; - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - dst[i] = static_cast(1) / (static_cast(1) + std::exp(-x)); - break; - case ActivationLayerInfo::ActivationFunction::RELU: - dst[i] = std::max(static_cast(0), x); - break; - case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: - dst[i] = std::min(a, std::max(static_cast(0), x)); - break; - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - dst[i] = (x > 0) ? x : a * x; - break; - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - dst[i] = std::log(static_cast(1) + std::exp(x)); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - dst[i] = std::sqrt(x); - break; - case ActivationLayerInfo::ActivationFunction::SQUARE: - dst[i] = x * x; - break; - case ActivationLayerInfo::ActivationFunction::TANH: - dst[i] = a * std::tanh(b * x); - break; - default: - ARM_COMPUTE_ERROR("Unsupported activation function"); - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int fixed_point_position = src.fixed_point_position(); - const fixed_point a(info.a(), fixed_point_position); - const fixed_point b(info.b(), fixed_point_position); - const fixed_point const_0(0, fixed_point_position); - const fixed_point const_1(1, fixed_point_position); - - for(int i = 0; i < src.num_elements(); ++i) - { - fixed_point x(src[i], fixed_point_position, true); - - switch(info.activation()) - { - case ActivationLayerInfo::ActivationFunction::ABS: - dst[i] = abs(x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LINEAR: - dst[i] = add(b, mul(a, x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - dst[i] = (const_1 / (const_1 + exp(-x))).raw(); - break; - case ActivationLayerInfo::ActivationFunction::RELU: - dst[i] = max(const_0, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::BOUNDED_RELU: - dst[i] = min(a, max(const_0, x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::LEAKY_RELU: - dst[i] = (x > const_0) ? x.raw() : mul(a, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - dst[i] = log(const_1 + exp(x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - dst[i] = (const_1 / inv_sqrt(x)).raw(); - break; - case ActivationLayerInfo::ActivationFunction::SQUARE: - dst[i] = mul(x, x).raw(); - break; - case ActivationLayerInfo::ActivationFunction::TANH: - dst[i] = mul(a, tanh(mul(b, x))).raw(); - break; - default: - ARM_COMPUTE_ERROR("Unsupported activation function"); - } - } - - return dst; -} - -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -template SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ActivationLayer.h b/tests/validation_new/CPP/ActivationLayer.h deleted file mode 100644 index 3f10a2f360..0000000000 --- a/tests/validation_new/CPP/ActivationLayer.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor activation_layer(const SimpleTensor &src, ActivationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_ACTIVATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/BitwiseAnd.cpp b/tests/validation_new/CPP/BitwiseAnd.cpp deleted file mode 100644 index 6fc46b402b..0000000000 --- a/tests/validation_new/CPP/BitwiseAnd.cpp +++ /dev/null @@ -1,51 +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 "BitwiseAnd.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] & src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseAnd.h b/tests/validation_new/CPP/BitwiseAnd.h deleted file mode 100644 index eba2fd695f..0000000000 --- a/tests/validation_new/CPP/BitwiseAnd.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_AND_H__ -#define __ARM_COMPUTE_TEST_BITWISE_AND_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_and(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_AND_H__ */ diff --git a/tests/validation_new/CPP/BitwiseNot.cpp b/tests/validation_new/CPP/BitwiseNot.cpp deleted file mode 100644 index 5a6a13b56c..0000000000 --- a/tests/validation_new/CPP/BitwiseNot.cpp +++ /dev/null @@ -1,51 +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 "BitwiseNot.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_not(const SimpleTensor &src) -{ - SimpleTensor dst(src.shape(), src.data_type()); - - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = ~src[i]; - } - - return dst; -} - -template SimpleTensor bitwise_not(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseNot.h b/tests/validation_new/CPP/BitwiseNot.h deleted file mode 100644 index b4206f9388..0000000000 --- a/tests/validation_new/CPP/BitwiseNot.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_NOT_H__ -#define __ARM_COMPUTE_TEST_BITWISE_NOT_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_not(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_NOT_H__ */ diff --git a/tests/validation_new/CPP/BitwiseOr.cpp b/tests/validation_new/CPP/BitwiseOr.cpp deleted file mode 100644 index fc258d54f1..0000000000 --- a/tests/validation_new/CPP/BitwiseOr.cpp +++ /dev/null @@ -1,51 +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 "BitwiseOr.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] | src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseOr.h b/tests/validation_new/CPP/BitwiseOr.h deleted file mode 100644 index 39158cb411..0000000000 --- a/tests/validation_new/CPP/BitwiseOr.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_OR_H__ -#define __ARM_COMPUTE_TEST_BITWISE_OR_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_or(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_OR_H__ */ diff --git a/tests/validation_new/CPP/BitwiseXor.cpp b/tests/validation_new/CPP/BitwiseXor.cpp deleted file mode 100644 index b8d275d8b5..0000000000 --- a/tests/validation_new/CPP/BitwiseXor.cpp +++ /dev/null @@ -1,51 +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 "BitwiseXor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2) -{ - SimpleTensor dst(src1.shape(), src1.data_type()); - - for(int i = 0; i < src1.num_elements(); ++i) - { - dst[i] = src1[i] ^ src2[i]; - } - - return dst; -} - -template SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/BitwiseXor.h b/tests/validation_new/CPP/BitwiseXor.h deleted file mode 100644 index 3e7721e843..0000000000 --- a/tests/validation_new/CPP/BitwiseXor.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_BITWISE_XOR_H__ -#define __ARM_COMPUTE_TEST_BITWISE_XOR_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor bitwise_xor(const SimpleTensor &src1, const SimpleTensor &src2); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BITWISE_XOR_H__ */ diff --git a/tests/validation_new/CPP/ConvolutionLayer.cpp b/tests/validation_new/CPP/ConvolutionLayer.cpp deleted file mode 100644 index a24621a3f2..0000000000 --- a/tests/validation_new/CPP/ConvolutionLayer.cpp +++ /dev/null @@ -1,205 +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 "ConvolutionLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -inline bool is_valid_pixel(int i, int min, int max) -{ - return (i >= min && i < max); -} - -// 3D convolution for floating point type -template ::value, int>::type = 0> -void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, int fixed_point_position) -{ - ARM_COMPUTE_UNUSED(fixed_point_position); - - const int half_width_weights = width_weights / 2; - const int half_height_weights = height_weights / 2; - - // Reset accumulator - T acc(0); - - // Compute a 2D convolution for each IFM and accumulate the result - for(int ifm = 0; ifm < depth_in; ++ifm) - { - // Compute the offset for the input slice - const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; - - // Compute 2D convolution - for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) - { - for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) - { - // Check if the pixel is out-of-bound - if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) - { - const int idx = xk + half_width_weights; - const int idy = yk + half_height_weights; - - const T i_value = in[offset_slice_in + xk + yk * width_in]; - const T w_value = weights[idx + idy * width_weights + ifm * width_weights * height_weights]; - - acc += i_value * w_value; - } - } - } - } - - // Accumulate the bias and store the result - *out = acc + (*bias); -} - -// 3D convolution for fixed point type -template ::value, int>::type = 0> -void convolution3d(const T *in, const T *weights, const T *bias, T *out, int xi, int yi, int width_in, int height_in, int depth_in, int width_weights, int height_weights, - int fixed_point_position) -{ - const int half_width_weights = width_weights / 2; - const int half_height_weights = height_weights / 2; - - using namespace fixed_point_arithmetic; - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - // Reset accumulator - fixed_point acc(0, fixed_point_position); - - // Compute a 2D convolution for each IFM and accumulate the result - for(int ifm = 0; ifm < depth_in; ++ifm) - { - // Compute the offset for the input slice - const int offset_slice_in = xi + yi * width_in + ifm * width_in * height_in; - - // Compute 2D convolution - for(int yk = -half_height_weights; yk <= half_height_weights; ++yk) - { - for(int xk = -half_width_weights; xk <= half_width_weights; ++xk) - { - // Check if the pixel is out-of-bound - if(is_valid_pixel(xi + xk, 0, width_in) && is_valid_pixel(yi + yk, 0, height_in)) - { - const int idx = xk + half_width_weights; - const int idy = yk + half_height_weights; - - const fixed_point i_value(in[offset_slice_in + xk + yk * width_in], fixed_point_position, true); - const fixed_point w_value(weights[idx + idy * width_weights + ifm * width_weights * height_weights], fixed_point_position, true); - const fixed_point iw = i_value * w_value; - acc = iw + acc; - } - } - } - } - - // Get the bias - const fixed_point b(*bias, fixed_point_position, true); - - // Accumulate the bias and covert back - acc = acc + b; - fixed_point res(acc); - *out = res.raw(); -} -} // namespace - -template -SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info) -{ - // Create reference - SimpleTensor dst{ output_shape, src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int width_in = src.shape().x(); - const int height_in = src.shape().y(); - const int depth_in = src.shape().z(); - const int width_out = dst.shape().x(); - const int height_out = dst.shape().y(); - const int depth_out = dst.shape().z(); - const int width_weights = weights.shape().x(); - const int height_weights = weights.shape().y(); - const int depth_weights = weights.shape().z(); - const int pad_xi = std::min(static_cast(info.pad().first), width_weights / 2); - const int pad_yi = std::min(static_cast(info.pad().second), height_weights / 2); - const int start_xi = width_weights / 2 - pad_xi; - const int start_yi = height_weights / 2 - pad_yi; - const int end_xi = width_in - start_xi; - const int end_yi = height_in - start_yi; - const int stride_xi = info.stride().first; - const int stride_yi = info.stride().second; - const int num_batches = src.shape().total_size() / (width_in * height_in * depth_in); - - for(int r = 0; r < num_batches; ++r) - { - for(int yi = start_yi; yi < end_yi; yi += stride_yi) - { - for(int xi = start_xi; xi < end_xi; xi += stride_xi) - { - for(int ofm = 0; ofm < depth_out; ++ofm) - { - // Compute input and output offsets - const int offset_in = r * width_in * height_in * depth_in; - const int xo = (xi - start_xi) / stride_xi; - const int yo = (yi - start_yi) / stride_yi; - const int offset_out = xo + yo * width_out + ofm * width_out * height_out + r * width_out * height_out * depth_out; - - // Compute 3D convolution - convolution3d(src.data() + offset_in, - weights.data() + ofm * width_weights * height_weights * depth_weights, - bias.data() + ofm, - dst.data() + offset_out, - xi, yi, - width_in, height_in, depth_in, - width_weights, height_weights, - src.fixed_point_position()); - } - } - } - } - - return dst; -} - -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, - const TensorShape &output_shape, const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -template SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ConvolutionLayer.h b/tests/validation_new/CPP/ConvolutionLayer.h deleted file mode 100644 index a7c9e086a4..0000000000 --- a/tests/validation_new/CPP/ConvolutionLayer.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ -#define __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor convolution_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthConcatenateLayer.cpp b/tests/validation_new/CPP/DepthConcatenateLayer.cpp deleted file mode 100644 index c54c6c8568..0000000000 --- a/tests/validation_new/CPP/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,104 +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 "DepthConcatenateLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthconcatenate_layer(const std::vector> &srcs) -{ - // Create reference - std::vector shapes; - - for(const auto &src : srcs) - { - shapes.emplace_back(src.shape()); - } - - DataType dst_type = srcs.empty() ? DataType::UNKNOWN : srcs[0].data_type(); - TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); - SimpleTensor dst(dst_shape, dst_type); - - // Compute reference - int depth_offset = 0; - const int width_out = dst.shape().x(); - const int height_out = dst.shape().y(); - const int depth_out = dst.shape().z(); - const int out_stride_z = width_out * height_out; - const int batches = dst.shape().total_size_upper(3); - - // Set output tensor to 0 - std::fill_n(dst.data(), dst.num_elements(), 0); - - for(const auto &src : srcs) - { - ARM_COMPUTE_ERROR_ON(depth_offset >= depth_out); - ARM_COMPUTE_ERROR_ON(batches != static_cast(src.shape().total_size_upper(3))); - - const int width = src.shape().x(); - const int height = src.shape().y(); - const int depth = src.shape().z(); - const int x_diff = (width_out - width) / 2; - const int y_diff = (height_out - height) / 2; - - const T *src_ptr = src.data(); - - for(int b = 0; b < batches; ++b) - { - const size_t offset_to_first_element = b * out_stride_z * depth_out + depth_offset * out_stride_z + y_diff * width_out + x_diff; - - for(int d = 0; d < depth; ++d) - { - for(int r = 0; r < height; ++r) - { - std::copy(src_ptr, src_ptr + width, dst.data() + offset_to_first_element + d * out_stride_z + r * width_out); - src_ptr += width; - } - } - } - - depth_offset += depth; - } - - return dst; -} - -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -template SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthConcatenateLayer.h b/tests/validation_new/CPP/DepthConcatenateLayer.h deleted file mode 100644 index 3c486a8015..0000000000 --- a/tests/validation_new/CPP/DepthConcatenateLayer.h +++ /dev/null @@ -1,45 +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. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ - -#include "tests/SimpleTensor.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthconcatenate_layer(const std::vector> &srcs); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthwiseConvolution.cpp b/tests/validation_new/CPP/DepthwiseConvolution.cpp deleted file mode 100644 index 8c5cec596e..0000000000 --- a/tests/validation_new/CPP/DepthwiseConvolution.cpp +++ /dev/null @@ -1,103 +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 "DepthwiseConvolution.h" - -#include "ConvolutionLayer.h" -#include "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -/** Perform a depthwise convolution - * - * - Three dimensions tensors - * - Third dimention is number of channels - * - Depths of input tensor and filter are equals - * - Padding, stride and output shape "match" - * - */ -template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info) -{ - // Create reference - SimpleTensor dst{ dst_shape, src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const size_t filter_width = weights.shape().x(); - const size_t filter_height = weights.shape().y(); - const size_t filter_plane = filter_width * filter_height; - const size_t input_width = src.shape().x(); - const size_t input_height = src.shape().y(); - const size_t input_depth = src.shape().z(); - - const size_t filter_half_size = filter_width / 2; - const size_t pad_x = std::min(filter_half_size, static_cast(conv_info.pad().first)); - const size_t pad_y = std::min(filter_half_size, static_cast(conv_info.pad().second)); - const size_t minimum_x = -pad_x + filter_half_size; - const size_t minimum_y = -pad_y + filter_half_size; - - int out_pos = 0; - for(size_t z = 0; z < input_depth; ++z) - { - for(size_t y = minimum_y; y < input_height + pad_y - filter_half_size; y += conv_info.stride().second) - { - for(size_t x = minimum_x; x < input_width + pad_x - filter_half_size; x += conv_info.stride().first) - { - Coordinates coords(static_cast(x), static_cast(y), static_cast(z)); - size_t filter_offset = filter_plane * z; - - T val = 0; - for(int j = y - filter_half_size; j <= static_cast(y + filter_half_size); ++j) - { - for(int i = x - filter_half_size; i <= static_cast(x + filter_half_size); ++i) - { - coords.set(0, i); - coords.set(1, j); - val += *(weights.data() + filter_offset) * tensor_elem_at(src, coords, BorderMode::CONSTANT, 0.f); - ++filter_offset; - } - } - coords.set(0, x); - coords.set(1, y); - dst[out_pos++] = saturate_cast(val); - } - } - } - - return dst; -} - -template SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthwiseConvolution.h b/tests/validation_new/CPP/DepthwiseConvolution.h deleted file mode 100644 index 4a92620880..0000000000 --- a/tests/validation_new/CPP/DepthwiseConvolution.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ -#define __ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthwise_convolution(const SimpleTensor &src, const SimpleTensor &weights, const TensorShape &dst_shape, const PadStrideInfo &conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp b/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp deleted file mode 100644 index eba0a19189..0000000000 --- a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.cpp +++ /dev/null @@ -1,60 +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 "DepthwiseConvolution.h" - -#include "DepthwiseSeparableConvolutionLayer.h" - -#include "ConvolutionLayer.h" -#include "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -// Depthwise separable convolution layer -template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info) -{ - // Compute reference - SimpleTensor depthwise_out = depthwise_convolution(src, depthwise_weights, depthwise_out_shape, depthwise_conv_info); - SimpleTensor dst = convolution_layer(depthwise_out, pointwise_weights, biases, dst_shape, pointwise_conv_info); - - return dst; -} - -template SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &in, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h b/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h deleted file mode 100644 index 0c9f118b84..0000000000 --- a/tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h +++ /dev/null @@ -1,46 +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. - */ -#ifndef __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor depthwise_separable_convolution_layer(const SimpleTensor &src, const SimpleTensor &depthwise_weights, const TensorShape &depthwise_out_shape, - const SimpleTensor &pointwise_weights, - const SimpleTensor &biases, const TensorShape &dst_shape, const PadStrideInfo &depthwise_conv_info, const PadStrideInfo &pointwise_conv_info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/DequantizationLayer.cpp b/tests/validation_new/CPP/DequantizationLayer.cpp deleted file mode 100644 index 1c7ec25255..0000000000 --- a/tests/validation_new/CPP/DequantizationLayer.cpp +++ /dev/null @@ -1,55 +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 "DequantizationLayer.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max) -{ - // Create reference - SimpleTensor dst{ src.shape(), DataType::F32 }; - - const float range = max - min; - const float scaling = range / 255.0f; - - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = (static_cast(src[i]) * scaling) + min; - } - - return dst; -} - -template SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/DequantizationLayer.h b/tests/validation_new/CPP/DequantizationLayer.h deleted file mode 100644 index 33592b89b8..0000000000 --- a/tests/validation_new/CPP/DequantizationLayer.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor dequantization_layer(const SimpleTensor &src, float min, float max); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/Floor.cpp b/tests/validation_new/CPP/Floor.cpp deleted file mode 100644 index aed4fecd01..0000000000 --- a/tests/validation_new/CPP/Floor.cpp +++ /dev/null @@ -1,57 +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 "Floor.h" - -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor floor_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type() }; - - // Compute reference - for(int i = 0; i < src.num_elements(); ++i) - { - dst[i] = std::floor(src[i]); - } - - return dst; -} - -template SimpleTensor floor_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/Floor.h b/tests/validation_new/CPP/Floor.h deleted file mode 100644 index 30b8118622..0000000000 --- a/tests/validation_new/CPP/Floor.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_FLOOR_H__ -#define __ARM_COMPUTE_TEST_FLOOR_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor floor_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation_new/CPP/FullyConnectedLayer.cpp b/tests/validation_new/CPP/FullyConnectedLayer.cpp deleted file mode 100644 index 7852dab27b..0000000000 --- a/tests/validation_new/CPP/FullyConnectedLayer.cpp +++ /dev/null @@ -1,133 +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 "FullyConnectedLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -// Vector matrix multiply for floating point -template ::value, int>::type = 0> -void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) -{ - ARM_COMPUTE_UNUSED(fixed_point_position); - - for(int y = 0; y < rows_weights; ++y) - { - dst[y] = std::inner_product(src, src + cols_weights, weights, static_cast(0)) + bias[y]; - weights += cols_weights; - } -} - -// Vector matrix multiply for fixed point type -template ::value, int>::type = 0> -void vector_matrix_multiply(const T *src, const T *weights, const T *bias, T *dst, int cols_weights, int rows_weights, uint8_t fixed_point_position) -{ - using namespace fixed_point_arithmetic; - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - for(int y = 0; y < rows_weights; ++y) - { - // Reset accumulator - fixed_point acc(0, fixed_point_position); - - for(int x = 0; x < cols_weights; ++x) - { - const fixed_point i_value(src[x], fixed_point_position, true); - const fixed_point w_value(weights[x], fixed_point_position, true); - acc = acc + i_value * w_value; - } - - // Get the bias - const fixed_point b(bias[y], fixed_point_position, true); - - // Convert back and accumulate the bias - fixed_point res(acc); - res = res + b; - - // Store the result - dst[y] = res.raw(); - - weights += cols_weights; - } -} -} // namespace - -template -SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape) -{ - // Create reference - SimpleTensor dst{ TensorShape{ dst_shape }, src.data_type(), 1, src.fixed_point_position() }; - - // Sanity checks - const int num_batch_dimensions = std::max(0, static_cast(dst_shape.num_dimensions()) - 1); - const int num_input_dimensions = src.shape().num_dimensions() - num_batch_dimensions; - const unsigned int linear_input_size = src.shape().total_size_lower(num_input_dimensions); - - ARM_COMPUTE_UNUSED(num_batch_dimensions); - ARM_COMPUTE_UNUSED(num_input_dimensions); - ARM_COMPUTE_UNUSED(linear_input_size); - ARM_COMPUTE_ERROR_ON(weights.shape().x() != linear_input_size); - ARM_COMPUTE_ERROR_ON(weights.shape().y() != bias.shape().x()); - ARM_COMPUTE_ERROR_ON(weights.shape().y() != dst.shape().x()); - - // Compute reference - const int cols_weights = weights.shape().x(); - const int rows_weights = weights.shape().y(); - const int num_batches = dst_shape.total_size_upper(1); - - for(int k = 0; k < num_batches; ++k) - { - vector_matrix_multiply(src.data() + k * cols_weights, - weights.data(), - bias.data(), - dst.data() + k * rows_weights, - cols_weights, - rows_weights, - src.fixed_point_position()); - } - - return dst; -} - -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, - const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -template SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/FullyConnectedLayer.h b/tests/validation_new/CPP/FullyConnectedLayer.h deleted file mode 100644 index 5d62179f57..0000000000 --- a/tests/validation_new/CPP/FullyConnectedLayer.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ -#define __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor fully_connected_layer(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &dst_shape); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_H__ */ diff --git a/tests/validation_new/CPP/GEMM.cpp b/tests/validation_new/CPP/GEMM.cpp deleted file mode 100644 index 424633f8e7..0000000000 --- a/tests/validation_new/CPP/GEMM.cpp +++ /dev/null @@ -1,122 +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 "GEMM.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) -{ - // Create reference - SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; - - // Compute reference - const int M = dst.shape().y(); - const int N = dst.shape().x(); - const int K = a.shape().x(); - - for(int row = 0; row < M; ++row) - { - for(int col = 0; col < N; ++col) - { - T acc(0); - - for(int k = 0; k < K; ++k) - { - acc += a[row * K + k] * b[k * N + col]; - } - - // Finalize the result: alpha * A * B + beta * C - dst[col + row * N] = alpha * acc + beta * c[col + row * N]; - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ c.shape(), c.data_type(), 1, c.fixed_point_position() }; - - // Compute reference - using promoted_type = fixed_point_arithmetic::traits::promote_t; - - const int M = dst.shape().y(); - const int N = dst.shape().x(); - const int K = a.shape().x(); - const int fixed_point_position = a.fixed_point_position(); - - const fixed_point alpha_q(alpha, fixed_point_position); - const fixed_point beta_q(beta, fixed_point_position); - - for(int row = 0; row < M; ++row) - { - for(int col = 0; col < N; ++col) - { - fixed_point acc_q(0, fixed_point_position); - - for(int k = 0; k < K; ++k) - { - const fixed_point a0_q(a[row * K + k], fixed_point_position, true); - const fixed_point b0_q(b[k * N + col], fixed_point_position, true); - - acc_q = acc_q + (a0_q * b0_q); - } - - // Finalize the result: alpha * A * B + beta * C - const fixed_point c0_q(c[col + row * N], fixed_point_position, true); - - fixed_point res_q(acc_q); - res_q = alpha_q * res_q; - res_q = res_q + (beta_q * c0_q); - - // Store the result - dst[col + row * N] = res_q.raw(); - } - } - - return dst; -} - -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -template SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/GEMM.h b/tests/validation_new/CPP/GEMM.h deleted file mode 100644 index 7fea2a9862..0000000000 --- a/tests/validation_new/CPP/GEMM.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef __ARM_COMPUTE_TEST_GEMM_H__ -#define __ARM_COMPUTE_TEST_GEMM_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); - -template ::value, int>::type = 0> -SimpleTensor gemm(const SimpleTensor &a, const SimpleTensor &b, const SimpleTensor &c, float alpha, float beta); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_GEMM_H__ */ diff --git a/tests/validation_new/CPP/L2Normalize.cpp b/tests/validation_new/CPP/L2Normalize.cpp deleted file mode 100644 index f423702819..0000000000 --- a/tests/validation_new/CPP/L2Normalize.cpp +++ /dev/null @@ -1,88 +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 "L2Normalize.h" -#include "ReductionOperation.h" - -#include "tests/validation_new/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -TensorShape get_output_shape(TensorShape shape, unsigned int axis) -{ - TensorShape output_shape(shape); - output_shape.set(axis, 1); - return output_shape; -} -} // namespace - -template -SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type() }; - - // Reduce across given axis - SimpleTensor sum = reduction_operation(src, get_output_shape(src.shape(), axis), axis, ReductionOperation::SUM_SQUARE); - - // Compute reference - const int elems = src.shape()[axis]; - const int upper_dims = src.shape().total_size_upper(axis + 1); - - for(int du = 0; du < upper_dims; ++du) - { - if(axis == 0) - { - const T *src_row_ptr = src.data() + du * elems; - T *dst_row_ptr = dst.data() + du * elems; - const T normalization_value = std::sqrt(std::max(sum[du], epsilon)); - std::transform(src_row_ptr, src_row_ptr + elems, dst_row_ptr, [normalization_value](T val) - { - return val / normalization_value; - }); - } - else - { - ARM_COMPUTE_ERROR("Unsupported normalization axis"); - } - } - - return dst; -} - -template SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/L2Normalize.h b/tests/validation_new/CPP/L2Normalize.h deleted file mode 100644 index da36a73bba..0000000000 --- a/tests/validation_new/CPP/L2Normalize.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_L2NORMALIZE_H__ -#define __ARM_COMPUTE_TEST_L2NORMALIZE_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor l2_normalize(const SimpleTensor &src, unsigned int axis, float epsilon); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_L2NORMALIZE_H__ */ diff --git a/tests/validation_new/CPP/MeanStdDev.cpp b/tests/validation_new/CPP/MeanStdDev.cpp deleted file mode 100644 index 4a39b13d56..0000000000 --- a/tests/validation_new/CPP/MeanStdDev.cpp +++ /dev/null @@ -1,57 +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 "MeanStdDev.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair mean_and_standard_deviation(const SimpleTensor &in) -{ - const int num_elements = in.num_elements(); - - // Calculate mean - float mean = std::accumulate(in.data(), in.data() + num_elements, 0.f) / num_elements; - - // Calculate standard deviation - float std_dev = std::accumulate(in.data(), in.data() + num_elements, 0.f, [&mean](float a, float b) - { - return a + (mean - b) * (mean - b); - }); - - std_dev = std::sqrt(std_dev / num_elements); - - return std::make_pair(mean, std_dev); -} - -template std::pair mean_and_standard_deviation(const SimpleTensor &in); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/MeanStdDev.h b/tests/validation_new/CPP/MeanStdDev.h deleted file mode 100644 index 6b89ae0656..0000000000 --- a/tests/validation_new/CPP/MeanStdDev.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ -#define __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -std::pair mean_and_standard_deviation(const SimpleTensor &in); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_STD_MEAN_DEV_H__ */ diff --git a/tests/validation_new/CPP/NormalizationLayer.cpp b/tests/validation_new/CPP/NormalizationLayer.cpp deleted file mode 100644 index a8818d8b5c..0000000000 --- a/tests/validation_new/CPP/NormalizationLayer.cpp +++ /dev/null @@ -1,275 +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 "NormalizationLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const uint32_t norm_size = info.norm_size(); - NormType type = info.type(); - float beta = info.beta(); - uint32_t kappa = info.kappa(); - - const int cols = src.shape()[0]; - const int rows = src.shape()[1]; - const int depth = src.shape()[2]; - int upper_dims = src.shape().total_size() / (cols * rows); - - float coeff = info.scale_coeff(); - int radius_cols = norm_size / 2; - - // IN_MAP_1D and CROSS_MAP normalize over a single axis only - int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; - - if(type == NormType::CROSS_MAP) - { - // Remove also depth from upper dimensions since it is the dimension we - // want to use for normalization - upper_dims /= depth; - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - for(int l = 0; l < depth; ++l) - { - float accumulated_scale = 0.f; - - for(int j = -radius_cols; j <= radius_cols; ++j) - { - const int z = l + j; - - if(z >= 0 && z < depth) - { - const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; - accumulated_scale += value * value; - } - } - - dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = kappa + accumulated_scale * coeff; - } - } - } - } - } - else - { - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - float accumulated_scale = 0.f; - - for(int j = -radius_rows; j <= radius_rows; ++j) - { - const int y = i + j; - for(int l = -radius_cols; l <= radius_cols; ++l) - { - const int x = k + l; - - if((x >= 0 && y >= 0) && (x < cols && y < rows)) - { - const T value = src[x + y * cols + r * cols * rows]; - accumulated_scale += value * value; - } - } - } - - dst[k + i * cols + r * cols * rows] = kappa + accumulated_scale * coeff; - } - } - } - } - - if(beta == 1.f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] / dst[i]; - } - } - else if(beta == 0.5f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] / std::sqrt(dst[i]); - } - } - else - { - for(int i = 0; i < dst.num_elements(); ++i) - { - dst[i] = src[i] * std::exp(std::log(dst[i]) * -beta); - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int fixed_point_position = src.fixed_point_position(); - - const uint32_t norm_size = info.norm_size(); - NormType type = info.type(); - fixed_point beta(info.beta(), fixed_point_position); - fixed_point kappa(info.kappa(), fixed_point_position); - - const int cols = src.shape()[0]; - const int rows = src.shape()[1]; - const int depth = src.shape()[2]; - int upper_dims = src.shape().total_size() / (cols * rows); - - fixed_point coeff(info.scale_coeff(), fixed_point_position); - int radius_cols = norm_size / 2; - - // IN_MAP_1D and CROSS_MAP normalize over a single axis only - int radius_rows = (NormType::IN_MAP_2D == type) ? norm_size / 2 : 0; - - if(type == NormType::CROSS_MAP) - { - // Remove also depth from upper dimensions since it is the dimension we - // want to use for normalization - upper_dims /= depth; - - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - for(int l = 0; l < depth; ++l) - { - fixed_point accumulated_scale(0.f, fixed_point_position); - - for(int j = -radius_cols; j <= radius_cols; ++j) - { - const int z = l + j; - - if(z >= 0 && z < depth) - { - const T value = src[k + i * cols + z * rows * cols + r * cols * rows * depth]; - const fixed_point fp_value(value, fixed_point_position, true); - accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); - } - } - - accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); - dst[k + i * cols + l * rows * cols + r * cols * rows * depth] = accumulated_scale.raw(); - } - } - } - } - } - else - { - for(int r = 0; r < upper_dims; ++r) - { - for(int i = 0; i < rows; ++i) - { - for(int k = 0; k < cols; ++k) - { - fixed_point accumulated_scale(0.f, fixed_point_position); - - for(int j = -radius_rows; j <= radius_rows; ++j) - { - const int y = i + j; - - for(int l = -radius_cols; l <= radius_cols; ++l) - { - const int x = k + l; - - if((x >= 0 && y >= 0) && (x < cols && y < rows)) - { - const T value = src[x + y * cols + r * cols * rows]; - const fixed_point fp_value(value, fixed_point_position, true); - accumulated_scale = add(accumulated_scale, mul(fp_value, fp_value)); - } - } - } - - accumulated_scale = add(kappa, mul(accumulated_scale, coeff)); - dst[k + i * cols + r * cols * rows] = accumulated_scale.raw(); - } - } - } - } - - if(info.beta() == 1.f) - { - for(int i = 0; i < dst.num_elements(); ++i) - { - fixed_point res = div(fixed_point(src[i], fixed_point_position, true), fixed_point(dst[i], fixed_point_position, true)); - dst[i] = res.raw(); - } - } - else - { - const fixed_point beta(info.beta(), fixed_point_position); - - for(int i = 0; i < dst.num_elements(); ++i) - { - fixed_point res = pow(fixed_point(dst[i], fixed_point_position, true), beta); - res = div(fixed_point(src[i], fixed_point_position, true), res); - dst[i] = res.raw(); - } - } - - return dst; -} - -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -template SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/NormalizationLayer.h b/tests/validation_new/CPP/NormalizationLayer.h deleted file mode 100644 index bdd87545ca..0000000000 --- a/tests/validation_new/CPP/NormalizationLayer.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor normalization_layer(const SimpleTensor &src, NormalizationLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/PoolingLayer.cpp b/tests/validation_new/CPP/PoolingLayer.cpp deleted file mode 100644 index 5464885dc4..0000000000 --- a/tests/validation_new/CPP/PoolingLayer.cpp +++ /dev/null @@ -1,243 +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 "PoolingLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -TensorShape calculate_output_shape(TensorShape shape, PoolingLayerInfo info) -{ - TensorShape dst_shape = shape; - const std::pair scaled_dims = arm_compute::scaled_dimensions(shape.x(), - shape.y(), - info.pool_size(), - info.pool_size(), - info.pad_stride_info()); - dst_shape.set(0, scaled_dims.first); - dst_shape.set(1, scaled_dims.second); - - return dst_shape; -} -} // namespace - -template ::value, int>::type> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) -{ - const int pool_size = info.pool_size(); - PoolingType type = info.pool_type(); - int pool_stride_x = info.pad_stride_info().stride().first; - int pool_stride_y = info.pad_stride_info().stride().second; - int pad_x = info.pad_stride_info().pad().first; - int pad_y = info.pad_stride_info().pad().second; - - const auto w_src = static_cast(src.shape()[0]); - const auto h_src = static_cast(src.shape()[1]); - const int upper_dims = src.shape().total_size() / (w_src * h_src); - - // Create reference - SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; - - const auto w_dst = static_cast(dst.shape()[0]); - const auto h_dst = static_cast(dst.shape()[1]); - - if(type == PoolingType::MAX) - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src); - int hend = std::min(hstart + pool_size, h_src); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - - T max_val = std::numeric_limits::lowest(); - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const T val = src[r * h_src * w_src + y * w_src + x]; - if(val > max_val) - { - max_val = val; - } - } - } - - dst[r * h_dst * w_dst + h * w_dst + w] = max_val; - } - } - } - } - else // Average pooling - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - T avg_val(0); - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src + pad_x); - int hend = std::min(hstart + pool_size, h_src + pad_y); - int pool = (hend - hstart) * (wend - wstart); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - wend = std::min(wend, w_src); - hend = std::min(hend, h_src); - - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - avg_val += src[r * h_src * w_src + y * w_src + x]; - } - } - dst[r * h_dst * w_dst + h * w_dst + w] = avg_val / pool; - } - } - } - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info) -{ - const int pool_size = info.pool_size(); - PoolingType type = info.pool_type(); - int pool_stride_x = info.pad_stride_info().stride().first; - int pool_stride_y = info.pad_stride_info().stride().second; - int pad_x = info.pad_stride_info().pad().first; - int pad_y = info.pad_stride_info().pad().second; - - const auto w_src = static_cast(src.shape()[0]); - const auto h_src = static_cast(src.shape()[1]); - const int upper_dims = src.shape().total_size() / (w_src * h_src); - - // Create reference - SimpleTensor dst{ calculate_output_shape(src.shape(), info), src.data_type(), 1, src.fixed_point_position() }; - - const auto w_dst = static_cast(dst.shape()[0]); - const auto h_dst = static_cast(dst.shape()[1]); - - if(type == PoolingType::MAX) - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src); - int hend = std::min(hstart + pool_size, h_src); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - - T max_val = std::numeric_limits::lowest(); - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const T val = src[r * h_src * w_src + y * w_src + x]; - if(val > max_val) - { - max_val = val; - } - } - } - - dst[r * h_dst * w_dst + h * w_dst + w] = max_val; - } - } - } - } - else // Average pooling - { - for(int r = 0; r < upper_dims; ++r) - { - for(int h = 0; h < h_dst; ++h) - { - for(int w = 0; w < w_dst; ++w) - { - int wstart = w * pool_stride_x - pad_x; - int hstart = h * pool_stride_y - pad_y; - int wend = std::min(wstart + pool_size, w_src + pad_x); - int hend = std::min(hstart + pool_size, h_src + pad_y); - int pool = (hend - hstart) * (wend - wstart); - wstart = std::max(wstart, 0); - hstart = std::max(hstart, 0); - wend = std::min(wend, w_src); - hend = std::min(hend, h_src); - - using namespace fixed_point_arithmetic; - - const int fixed_point_position = src.fixed_point_position(); - const fixed_point invpool_fp(1.f / static_cast(pool), fixed_point_position); - fixed_point avg_val(0, fixed_point_position, true); - - for(int y = hstart; y < hend; ++y) - { - for(int x = wstart; x < wend; ++x) - { - const fixed_point in_fp(src[r * h_src * w_src + y * w_src + x], fixed_point_position, true); - avg_val = add(avg_val, in_fp); - } - } - dst[r * h_dst * w_dst + h * w_dst + w] = mul(avg_val, invpool_fp).raw(); - } - } - } - } - - return dst; -} - -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -template SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/PoolingLayer.h b/tests/validation_new/CPP/PoolingLayer.h deleted file mode 100644 index 0935fb02f9..0000000000 --- a/tests/validation_new/CPP/PoolingLayer.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef __ARM_COMPUTE_TEST_POOLING_LAYER_H__ -#define __ARM_COMPUTE_TEST_POOLING_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); - -template ::value, int>::type = 0> -SimpleTensor pooling_layer(const SimpleTensor &src, PoolingLayerInfo info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_POOLING_LAYER_H__ */ diff --git a/tests/validation_new/CPP/QuantizationLayer.cpp b/tests/validation_new/CPP/QuantizationLayer.cpp deleted file mode 100644 index d61e75a3a9..0000000000 --- a/tests/validation_new/CPP/QuantizationLayer.cpp +++ /dev/null @@ -1,85 +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 "QuantizationLayer.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -void compute_min_max(const SimpleTensor &src, float *min, float *max) -{ - // Set min and max to first pixel - float tmp_min = src[0]; - float tmp_max = src[0]; - - // Look for min and max values - for(int i = 1; i < src.num_elements(); ++i) - { - if(src[i] < tmp_min) - { - tmp_min = src[i]; - } - if(src[i] > tmp_max) - { - tmp_max = src[i]; - } - } - - *min = tmp_min; - *max = tmp_max; -} - -template ::value, int>::type> -SimpleTensor quantization_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), DataType::U8 }; - - // Compute min and max of the tensor using Min-Max layer - float min = 0.f; - float max = 0.f; - - compute_min_max(src, &min, &max); - - const float range = max - min; - - for(int i = 0; i < src.num_elements(); ++i) - { - // map values to range [0.0, 1.0] - const float normalized = (src[i] - min) / range; - dst[i] = static_cast(std::min(255.0f, normalized * 256.0f)); - } - - return dst; -} - -template SimpleTensor quantization_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/QuantizationLayer.h b/tests/validation_new/CPP/QuantizationLayer.h deleted file mode 100644 index c696ab0c85..0000000000 --- a/tests/validation_new/CPP/QuantizationLayer.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ -#define __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor quantization_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_QUANTIZATION_LAYER_H__ */ diff --git a/tests/validation_new/CPP/ReductionOperation.cpp b/tests/validation_new/CPP/ReductionOperation.cpp deleted file mode 100644 index f4c5c21182..0000000000 --- a/tests/validation_new/CPP/ReductionOperation.cpp +++ /dev/null @@ -1,93 +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 "ReductionOperation.h" - -#include "tests/validation_new/Helpers.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -namespace -{ -template -struct square -{ - T operator()(const T &lhs, const T &rhs) const - { - return (lhs + rhs * rhs); - } -}; - -template -T reduce_operation(T *ptr, int reduce_elements, ReductionOperation op) -{ - switch(op) - { - case ReductionOperation::SUM_SQUARE: - return std::accumulate(ptr, ptr + reduce_elements, 0.f, square()); - default: - ARM_COMPUTE_ERROR("Unsupported reduction operation"); - } -} -} // namespace - -template -SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op) -{ - // Create reference - SimpleTensor dst{ dst_shape, src.data_type() }; - - // Compute reference - const int reduce_elems = src.shape()[axis]; - const int upper_dims = src.shape().total_size_upper(axis + 1); - - for(int du = 0; du < upper_dims; ++du) - { - if(axis == 0) - { - const T *src_row_ptr = src.data() + du * reduce_elems; - dst[du] = reduce_operation(src_row_ptr, reduce_elems, op); - } - else - { - ARM_COMPUTE_ERROR("Unsupported reduction axis"); - } - } - - return dst; -} - -template SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/ReductionOperation.h b/tests/validation_new/CPP/ReductionOperation.h deleted file mode 100644 index 500a8162fd..0000000000 --- a/tests/validation_new/CPP/ReductionOperation.h +++ /dev/null @@ -1,44 +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. - */ -#ifndef __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ -#define __ARM_COMPUTE_TEST_REDUCTION_OPERATION_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor reduction_operation(const SimpleTensor &src, const TensorShape &dst_shape, unsigned int axis, ReductionOperation op); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_FLOOR_H__ */ diff --git a/tests/validation_new/CPP/Scale.cpp b/tests/validation_new/CPP/Scale.cpp deleted file mode 100644 index a1119f33b9..0000000000 --- a/tests/validation_new/CPP/Scale.cpp +++ /dev/null @@ -1,166 +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 "arm_compute/core/Helpers.h" - -#include "Scale.h" -#include "Utils.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) -{ - TensorShape shape_scaled(in.shape()); - shape_scaled.set(0, in.shape()[0] * scale_x); - shape_scaled.set(1, in.shape()[1] * scale_y); - SimpleTensor out(shape_scaled, in.data_type()); - - // Compute the ratio between source width/height and destination width/height - const auto wr = static_cast(in.shape()[0]) / static_cast(out.shape()[0]); - const auto hr = static_cast(in.shape()[1]) / static_cast(out.shape()[1]); - - const auto width = static_cast(in.shape().x()); - const auto height = static_cast(in.shape().y()); - - // Area interpolation behaves as Nearest Neighbour in case of up-sampling - if(policy == InterpolationPolicy::AREA && wr <= 1.f && hr <= 1.f) - { - policy = InterpolationPolicy::NEAREST_NEIGHBOR; - } - - for(int element_idx = 0, count = 0; element_idx < out.num_elements(); ++element_idx, ++count) - { - Coordinates id = index2coord(out.shape(), element_idx); - int idx = id.x(); - int idy = id.y(); - float x_src = (idx + 0.5f) * wr - 0.5f; - float y_src = (idy + 0.5f) * hr - 0.5f; - - switch(policy) - { - case InterpolationPolicy::NEAREST_NEIGHBOR: - { - //Calculate the source coords without -0.5f is equivalent to round the x_scr/y_src coords - x_src = (idx + 0.5f) * wr; - y_src = (idy + 0.5f) * hr; - id.set(0, x_src); - id.set(1, y_src); - - // If coordinates in range of tensor's width or height - if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) - { - out[element_idx] = tensor_elem_at(in, id, border_mode, constant_border_value); - } - else - { - if(border_mode == BorderMode::CONSTANT) - { - out[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, clamp(static_cast(x_src), 0, width - 1)); - id.set(1, clamp(static_cast(y_src), 0, height - 1)); - out[element_idx] = in[coord2index(in.shape(), id)]; - } - } - break; - } - case InterpolationPolicy::BILINEAR: - { - id.set(0, std::floor(x_src)); - id.set(1, std::floor(y_src)); - if(x_src >= -1 || y_src >= -1 || x_src <= width || y_src <= height) - { - out[element_idx] = bilinear_policy(in, id, x_src, y_src, border_mode, constant_border_value); - } - else - { - if(border_mode == BorderMode::CONSTANT) - { - out[element_idx] = constant_border_value; - } - else if(border_mode == BorderMode::REPLICATE) - { - id.set(0, clamp(static_cast(x_src), 0, width - 1)); - id.set(1, clamp(static_cast(y_src), 0, height - 1)); - out[element_idx] = in[coord2index(in.shape(), id)]; - } - } - break; - } - case InterpolationPolicy::AREA: - { - int x_from = std::floor(idx * wr - 0.5f - x_src); - int y_from = std::floor(idy * hr - 0.5f - y_src); - int x_to = std::ceil((idx + 1) * wr - 0.5f - x_src); - int y_to = std::ceil((idy + 1) * hr - 0.5f - y_src); - const int xi = std::floor(x_src); - const int yi = std::floor(y_src); - - // Clamp position to borders - x_src = std::max(-1.f, std::min(x_src, static_cast(width))); - y_src = std::max(-1.f, std::min(y_src, static_cast(height))); - - // Clamp bounding box offsets to borders - x_from = ((x_src + x_from) < -1) ? -1 : x_from; - y_from = ((y_src + y_from) < -1) ? -1 : y_from; - x_to = ((x_src + x_to) > width) ? (width - x_src) : x_to; - y_to = ((y_src + y_to) > height) ? (height - y_src) : y_to; - ARM_COMPUTE_ERROR_ON((x_to - x_from + 1) == 0 || (y_to - y_from + 1) == 0); - - float sum = 0; - for(int j = yi + y_from, je = yi + y_to; j <= je; ++j) - { - for(int i = xi + x_from, ie = xi + x_to; i <= ie; ++i) - { - id.set(0, static_cast(i)); - id.set(1, static_cast(j)); - sum += tensor_elem_at(in, id, border_mode, constant_border_value); - } - } - out[element_idx] = sum / ((x_to - x_from + 1) * (y_to - y_from + 1)); - - break; - } - default: - ARM_COMPUTE_ERROR("Unsupported interpolation mode"); - } - } - - return out; -} - -template SimpleTensor scale(const SimpleTensor &src, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute \ No newline at end of file diff --git a/tests/validation_new/CPP/Scale.h b/tests/validation_new/CPP/Scale.h deleted file mode 100644 index b882915946..0000000000 --- a/tests/validation_new/CPP/Scale.h +++ /dev/null @@ -1,43 +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. - */ -#ifndef __ARM_COMPUTE_TEST_SCALE_H__ -#define __ARM_COMPUTE_TEST_SCALE_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor scale(const SimpleTensor &in, float scale_x, float scale_y, InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value = 0); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SCALE_H__ */ diff --git a/tests/validation_new/CPP/SoftmaxLayer.cpp b/tests/validation_new/CPP/SoftmaxLayer.cpp deleted file mode 100644 index 8c2cda8296..0000000000 --- a/tests/validation_new/CPP/SoftmaxLayer.cpp +++ /dev/null @@ -1,122 +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 "SoftmaxLayer.h" - -#include "tests/validation_new/FixedPoint.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type> -SimpleTensor softmax_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int cols = src.shape()[0]; - const int upper_dims = src.num_elements() / cols; - - for(int r = 0; r < upper_dims; ++r) - { - const T *src_row_ptr = src.data() + r * cols; - T *dst_row_ptr = dst.data() + r * cols; - - // Find max - const T max = *std::max_element(src_row_ptr, src_row_ptr + cols); - - // Regularize - T sum(0.f); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&sum, max](T val) - { - const T res(std::exp(val - max)); - sum += res; - return res; - }); - - // Normalize - std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [sum](T val) - { - return val / sum; - }); - } - - return dst; -} - -template ::value, int>::type> -SimpleTensor softmax_layer(const SimpleTensor &src) -{ - using namespace fixed_point_arithmetic; - - // Create reference - SimpleTensor dst{ src.shape(), src.data_type(), 1, src.fixed_point_position() }; - - // Compute reference - const int cols = src.shape()[0]; - const int upper_dims = src.num_elements() / cols; - - for(int r = 0; r < upper_dims; ++r) - { - const T *src_row_ptr = src.data() + r * cols; - T *dst_row_ptr = dst.data() + r * cols; - - // Find max - const fixed_point max(*std::max_element(src_row_ptr, src_row_ptr + cols), src.fixed_point_position(), true); - - // Regularize - using promoted_type = fixed_point_arithmetic::traits::promote_t; - fixed_point sum(0, src.fixed_point_position(), true); - std::transform(src_row_ptr, src_row_ptr + cols, dst_row_ptr, [&](T val) - { - const fixed_point res = exp(fixed_point(val, src.fixed_point_position(), true) - max); - sum = add(sum, fixed_point(res.raw(), src.fixed_point_position(), true)); - return res.raw(); - }); - - // Normalize - fixed_point saturated_sum(sum); - std::transform(dst_row_ptr, dst_row_ptr + cols, dst_row_ptr, [&](T val) - { - return div(fixed_point(val, src.fixed_point_position(), true), saturated_sum).raw(); - }); - } - - return dst; -} - -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -template SimpleTensor softmax_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/SoftmaxLayer.h b/tests/validation_new/CPP/SoftmaxLayer.h deleted file mode 100644 index cc52f3cf51..0000000000 --- a/tests/validation_new/CPP/SoftmaxLayer.h +++ /dev/null @@ -1,47 +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. - */ -#ifndef __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ -#define __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ - -#include "tests/SimpleTensor.h" -#include "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template ::value, int>::type = 0> -SimpleTensor softmax_layer(const SimpleTensor &src); - -template ::value, int>::type = 0> -SimpleTensor softmax_layer(const SimpleTensor &src); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SOFTMAX_LAYER_H__ */ diff --git a/tests/validation_new/CPP/Utils.cpp b/tests/validation_new/CPP/Utils.cpp deleted file mode 100644 index c89807b69a..0000000000 --- a/tests/validation_new/CPP/Utils.cpp +++ /dev/null @@ -1,93 +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 "Utils.h" - -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Return a tensor element at a specified coordinate with different border modes -template -T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) -{ - const int x = coord.x(); - const int y = coord.y(); - const auto width = static_cast(in.shape().x()); - const auto height = static_cast(in.shape().y()); - - // If coordinates beyond range of tensor's width or height - if(x < 0 || y < 0 || x >= width || y >= height) - { - if(border_mode == BorderMode::REPLICATE) - { - coord.set(0, std::max(0, std::min(x, width - 1))); - coord.set(1, std::max(0, std::min(y, height - 1))); - } - else - { - return constant_border_value; - } - } - return in[coord2index(in.shape(), coord)]; -} -template float tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, float constant_border_value); -template uint8_t tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, uint8_t constant_border_value); - -// Return the bilinear value at a specified coordinate with different border modes -template -T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value) -{ - int idx = std::floor(xn); - int idy = std::floor(yn); - - const float dx = xn - idx; - const float dy = yn - idy; - const float dx_1 = 1.0f - dx; - const float dy_1 = 1.0f - dy; - - id.set(0, idx); - id.set(1, idy); - const T tl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy); - const T tr = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx); - id.set(1, idy + 1); - const T bl = tensor_elem_at(in, id, border_mode, constant_border_value); - id.set(0, idx + 1); - id.set(1, idy + 1); - const T br = tensor_elem_at(in, id, border_mode, constant_border_value); - - return tl * (dx_1 * dy_1) + tr * (dx * dy_1) + bl * (dx_1 * dy) + br * (dx * dy); -} -template uint8_t bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); - -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/CPP/Utils.h b/tests/validation_new/CPP/Utils.h deleted file mode 100644 index 4e3deb4d86..0000000000 --- a/tests/validation_new/CPP/Utils.h +++ /dev/null @@ -1,54 +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. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ - -#include "arm_compute/core/Types.h" -#include "tests/Globals.h" -#include "tests/ILutAccessor.h" -#include "tests/Types.h" -#include "tests/validation/ValidationUserConfiguration.h" -#include "tests/validation/half.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -T tensor_elem_at(const SimpleTensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value); - -template -T bilinear_policy(const SimpleTensor &in, Coordinates id, float xn, float yn, BorderMode border_mode, uint8_t constant_border_value); -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_UTILS_H__ */ diff --git a/tests/validation_new/FixedPoint.h b/tests/validation_new/FixedPoint.h deleted file mode 100644 index 61d791c54c..0000000000 --- a/tests/validation_new/FixedPoint.h +++ /dev/null @@ -1,984 +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. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ - -#include "Utils.h" -#include "support/ToolchainSupport.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace fixed_point_arithmetic -{ -namespace detail -{ -// Forward declare structs -struct functions; -template -struct constant_expr; -} - -/** Fixed point traits */ -namespace traits -{ -// Promote types -// *INDENT-OFF* -// clang-format off -template struct promote { }; -template <> struct promote { using type = uint16_t; }; -template <> struct promote { using type = int16_t; }; -template <> struct promote { using type = uint32_t; }; -template <> struct promote { using type = int32_t; }; -template <> struct promote { using type = uint64_t; }; -template <> struct promote { using type = int64_t; }; -template <> struct promote { using type = uint64_t; }; -template <> struct promote { using type = int64_t; }; -template -using promote_t = typename promote::type; -// clang-format on -// *INDENT-ON* -} - -/** Strongly typed enum class representing the overflow policy */ -enum class OverflowPolicy -{ - WRAP, /**< Wrap policy */ - SATURATE /**< Saturate policy */ -}; -/** Strongly typed enum class representing the rounding policy */ -enum class RoundingPolicy -{ - TO_ZERO, /**< Round to zero policy */ - TO_NEAREST_EVEN /**< Round to nearest even policy */ -}; - -/** Arbitrary fixed-point arithmetic class */ -template -class fixed_point -{ -public: - // Static Checks - static_assert(std::is_integral::value, "Type is not an integer"); - - /** Constructor (from different fixed point type) - * - * @param[in] val Fixed point - * @param[in] p Fixed point precision - */ - template - fixed_point(fixed_point val, uint8_t p) - : _value(0), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - T v = 0; - - if(std::numeric_limits::digits < std::numeric_limits::digits) - { - val.rescale(p); - v = detail::constant_expr::saturate_cast(val.raw()); - } - else - { - auto v_cast = static_cast>(val); - v_cast.rescale(p); - v = v_cast.raw(); - } - _value = static_cast(v); - } - /** Constructor (from integer) - * - * @param[in] val Integer value to be represented as fixed point - * @param[in] p Fixed point precision - * @param[in] is_raw If true val is a raw fixed point value else an integer - */ - template ::value>::type> - fixed_point(U val, uint8_t p, bool is_raw = false) - : _value(val << p), _fixed_point_position(p) - { - if(is_raw) - { - _value = val; - } - } - /** Constructor (from float) - * - * @param[in] val Float value to be represented as fixed point - * @param[in] p Fixed point precision - */ - fixed_point(float val, uint8_t p) - : _value(detail::constant_expr::to_fixed(val, p)), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - } - /** Constructor (from float string) - * - * @param[in] str Float string to be represented as fixed point - * @param[in] p Fixed point precision - */ - fixed_point(std::string str, uint8_t p) - : _value(detail::constant_expr::to_fixed(support::cpp11::stof(str), p)), _fixed_point_position(p) - { - assert(p > 0 && p < std::numeric_limits::digits); - } - /** Default copy constructor */ - fixed_point &operator=(const fixed_point &) = default; - /** Default move constructor */ - fixed_point &operator=(fixed_point &&) = default; - /** Default copy assignment operator */ - fixed_point(const fixed_point &) = default; - /** Default move assignment operator */ - fixed_point(fixed_point &&) = default; - - /** Float conversion operator - * - * @return Float representation of fixed point - */ - operator float() const - { - return detail::constant_expr::to_float(_value, _fixed_point_position); - } - /** Integer conversion operator - * - * @return Integer representation of fixed point - */ - template ::value>::type> - operator U() const - { - return detail::constant_expr::to_int(_value, _fixed_point_position); - } - /** Convert to different fixed point of different type but same precision - * - * @note Down-conversion might fail. - */ - template - operator fixed_point() - { - U val = static_cast(_value); - if(std::numeric_limits::digits < std::numeric_limits::digits) - { - val = detail::constant_expr::saturate_cast(_value); - } - return fixed_point(val, _fixed_point_position, true); - } - - /** Arithmetic += assignment operator - * - * @param[in] rhs Fixed point operand - * - * @return Reference to this fixed point - */ - template - fixed_point &operator+=(const fixed_point &rhs) - { - fixed_point val(rhs, _fixed_point_position); - _value += val.raw(); - return *this; - } - /** Arithmetic -= assignment operator - * - * @param[in] rhs Fixed point operand - * - * @return Reference to this fixed point - */ - template - fixed_point &operator-=(const fixed_point &rhs) - { - fixed_point val(rhs, _fixed_point_position); - _value -= val.raw(); - return *this; - } - - /** Raw value accessor - * - * @return Raw fixed point value - */ - T raw() const - { - return _value; - } - /** Precision accessor - * - * @return Precision of fixed point - */ - uint8_t precision() const - { - return _fixed_point_position; - } - /** Rescale a fixed point to a new precision - * - * @param[in] p New fixed point precision - */ - void rescale(uint8_t p) - { - assert(p > 0 && p < std::numeric_limits::digits); - - using promoted_T = typename traits::promote::type; - promoted_T val = _value; - if(p > _fixed_point_position) - { - val <<= (p - _fixed_point_position); - } - else if(p < _fixed_point_position) - { - uint8_t pbar = _fixed_point_position - p; - val += (pbar != 0) ? (1 << (pbar - 1)) : 0; - val >>= pbar; - } - - _value = detail::constant_expr::saturate_cast(val); - _fixed_point_position = p; - } - -private: - T _value; /**< Fixed point raw value */ - uint8_t _fixed_point_position; /**< Fixed point precision */ -}; - -namespace detail -{ -/** Count the number of leading zero bits in the given value. - * - * @param[in] value Input value. - * - * @return Number of leading zero bits. - */ -template -constexpr int clz(T value) -{ - using unsigned_T = typename std::make_unsigned::type; - // __builtin_clz is available for int. Need to correct reported number to - // match the original type. - return __builtin_clz(value) - (32 - std::numeric_limits::digits); -} - -template -struct constant_expr -{ - /** Calculate representation of 1 in fixed point given a fixed point precision - * - * @param[in] p Fixed point precision - * - * @return Representation of value 1 in fixed point. - */ - static constexpr T fixed_one(uint8_t p) - { - return (1 << p); - } - /** Calculate fixed point precision step given a fixed point precision - * - * @param[in] p Fixed point precision - * - * @return Fixed point precision step - */ - static constexpr float fixed_step(uint8_t p) - { - return (1.0f / static_cast(1 << p)); - } - - /** Convert a fixed point value to float given its precision. - * - * @param[in] val Fixed point value - * @param[in] p Fixed point precision - * - * @return Float representation of the fixed point number - */ - static constexpr float to_float(T val, uint8_t p) - { - return static_cast(val * fixed_step(p)); - } - /** Convert a fixed point value to integer given its precision. - * - * @param[in] val Fixed point value - * @param[in] p Fixed point precision - * - * @return Integer of the fixed point number - */ - static constexpr T to_int(T val, uint8_t p) - { - return val >> p; - } - /** Convert a single precision floating point value to a fixed point representation given its precision. - * - * @param[in] val Floating point value - * @param[in] p Fixed point precision - * - * @return The raw fixed point representation - */ - static constexpr T to_fixed(float val, uint8_t p) - { - return static_cast(saturate_cast(val * fixed_one(p) + ((val >= 0) ? 0.5 : -0.5))); - } - /** Clamp value between two ranges - * - * @param[in] val Value to clamp - * @param[in] min Minimum value to clamp to - * @param[in] max Maximum value to clamp to - * - * @return clamped value - */ - static constexpr T clamp(T val, T min, T max) - { - return std::min(std::max(val, min), max); - } - /** Saturate given number - * - * @param[in] val Value to saturate - * - * @return Saturated value - */ - template - static constexpr T saturate_cast(U val) - { - return static_cast(std::min(std::max(val, static_cast(std::numeric_limits::min())), static_cast(std::numeric_limits::max()))); - } -}; -struct functions -{ - /** Output stream operator - * - * @param[in] s Output stream - * @param[in] x Fixed point value - * - * @return Reference output to updated stream - */ - template - static std::basic_ostream &write(std::basic_ostream &s, fixed_point &x) - { - return s << static_cast(x); - } - /** Signbit of a fixed point number. - * - * @param[in] x Fixed point number - * - * @return True if negative else false. - */ - template - static bool signbit(fixed_point x) - { - return ((x.raw() >> std::numeric_limits::digits) != 0); - } - /** Checks if two fixed point numbers are equal - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed points are equal else false - */ - template - static bool isequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() == y.raw()); - } - /** Checks if two fixed point number are not equal - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed points are not equal else false - */ - template - static bool isnotequal(fixed_point x, fixed_point y) - { - return !isequal(x, y); - } - /** Checks if one fixed point is greater than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is greater than other - */ - template - static bool isgreater(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() > y.raw()); - } - /** Checks if one fixed point is greater or equal than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is greater or equal than other - */ - template - static bool isgreaterequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() >= y.raw()); - } - /** Checks if one fixed point is less than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less than other - */ - template - static bool isless(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() < y.raw()); - } - /** Checks if one fixed point is less or equal than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less or equal than other - */ - template - static bool islessequal(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - return (x.raw() <= y.raw()); - } - /** Checks if one fixed point is less or greater than the other - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return True if fixed point is less or greater than other - */ - template - static bool islessgreater(fixed_point x, fixed_point y) - { - return isnotequal(x, y); - } - /** Clamp fixed point to specific range. - * - * @param[in] x Fixed point operand - * @param[in] min Minimum value to clamp to - * @param[in] max Maximum value to clamp to - * - * @return Clamped result - */ - template - static fixed_point clamp(fixed_point x, T min, T max) - { - return fixed_point(constant_expr::clamp(x.raw(), min, max), x.precision(), true); - } - /** Negate number - * - * @param[in] x Fixed point operand - * - * @return Negated fixed point result - */ - template - static fixed_point negate(fixed_point x) - { - using promoted_T = typename traits::promote::type; - promoted_T val = -x.raw(); - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x.precision(), true); - } - /** Perform addition among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point add(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x.raw()) + static_cast(y.raw()); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x.raw() + y.raw(), p, true); - } - } - /** Perform subtraction among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point sub(fixed_point x, fixed_point y) - { - uint8_t p = std::min(x.precision(), y.precision()); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x.raw()) - static_cast(y.raw()); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x.raw() - y.raw(), p, true); - } - } - /** Perform multiplication among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point mul(fixed_point x, fixed_point y) - { - using promoted_T = typename traits::promote::type; - uint8_t p_min = std::min(x.precision(), y.precision()); - uint8_t p_max = std::max(x.precision(), y.precision()); - promoted_T round_factor = (1 << (p_max - 1)); - promoted_T val = ((static_cast(x.raw()) * static_cast(y.raw())) + round_factor) >> p_max; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), p_min, true); - } - /** Perform division among two fixed point numbers - * - * @param[in] x First fixed point operand - * @param[in] y Second fixed point operand - * - * @return Result fixed point with precision equal to minimum precision of both operands - */ - template - static fixed_point div(fixed_point x, fixed_point y) - { - using promoted_T = typename traits::promote::type; - uint8_t p = std::min(x.precision(), y.precision()); - promoted_T denom = static_cast(y.raw()); - if(denom != 0) - { - promoted_T val = (static_cast(x.raw()) << std::max(x.precision(), y.precision())) / denom; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), p, true); - } - else - { - T val = (x.raw() < 0) ? std::numeric_limits::min() : std::numeric_limits::max(); - return fixed_point(val, p, true); - } - } - /** Shift left - * - * @param[in] x Fixed point operand - * @param[in] shift Shift value - * - * @return Shifted value - */ - template - static fixed_point shift_left(fixed_point x, size_t shift) - { - using promoted_T = typename traits::promote::type; - promoted_T val = static_cast(x.raw()) << shift; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x.precision(), true); - } - /** Shift right - * - * @param[in] x Fixed point operand - * @param[in] shift Shift value - * - * @return Shifted value - */ - template - static fixed_point shift_right(fixed_point x, size_t shift) - { - return fixed_point(x.raw() >> shift, x.precision(), true); - } - /** Calculate absolute value - * - * @param[in] x Fixed point operand - * - * @return Absolute value of operand - */ - template - static fixed_point abs(fixed_point x) - { - using promoted_T = typename traits::promote::type; - T val = (x.raw() < 0) ? constant_expr::saturate_cast(-static_cast(x.raw())) : x.raw(); - return fixed_point(val, x.precision(), true); - } - /** Calculate the logarithm of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Logarithm value of operand - */ - template - static fixed_point log(fixed_point x) - { - uint8_t p = x.precision(); - auto const_one = fixed_point(static_cast(1), p); - - // Logarithm of 1 is zero and logarithm of negative values is not defined in R, so return 0. - // Also, log(x) == -log(1/x) for 0 < x < 1. - if(isequal(x, const_one) || islessequal(x, fixed_point(static_cast(0), p))) - { - return fixed_point(static_cast(0), p, true); - } - else if(isless(x, const_one)) - { - return mul(log(div(const_one, x)), fixed_point(-1, p)); - } - - // Remove even powers of 2 - T shift_val = 31 - __builtin_clz(x.raw() >> p); - x = shift_right(x, shift_val); - x = sub(x, const_one); - - // Constants - auto ln2 = fixed_point(0.6931471, p); - auto A = fixed_point(1.4384189, p); - auto B = fixed_point(-0.67719, p); - auto C = fixed_point(0.3218538, p); - auto D = fixed_point(-0.0832229, p); - - // Polynomial expansion - auto sum = add(mul(x, D), C); - sum = add(mul(x, sum), B); - sum = add(mul(x, sum), A); - sum = mul(x, sum); - - return mul(add(sum, fixed_point(static_cast(shift_val), p)), ln2); - } - /** Calculate the exponential of a fixed point number. - * - * exp(x) = exp(floor(x)) * exp(x - floor(x)) - * = pow(2, floor(x) / ln(2)) * exp(x - floor(x)) - * = exp(x - floor(x)) << (floor(x) / ln(2)) - * - * @param[in] x Fixed point operand - * - * @return Exponential value of operand - */ - template - static fixed_point exp(fixed_point x) - { - uint8_t p = x.precision(); - // Constants - auto const_one = fixed_point(1, p); - auto ln2 = fixed_point(0.6931471, p); - auto inv_ln2 = fixed_point(1.442695, p); - auto A = fixed_point(0.9978546, p); - auto B = fixed_point(0.4994721, p); - auto C = fixed_point(0.1763723, p); - auto D = fixed_point(0.0435108, p); - - T scaled_int_part = detail::constant_expr::to_int(mul(x, inv_ln2).raw(), p); - - // Polynomial expansion - auto frac_part = sub(x, mul(ln2, fixed_point(scaled_int_part, p))); - auto taylor = add(mul(frac_part, D), C); - taylor = add(mul(frac_part, taylor), B); - taylor = add(mul(frac_part, taylor), A); - taylor = mul(frac_part, taylor); - taylor = add(taylor, const_one); - - // Saturate value - if(static_cast(clz(taylor.raw())) <= scaled_int_part) - { - return fixed_point(std::numeric_limits::max(), p, true); - } - - return (scaled_int_part < 0) ? shift_right(taylor, -scaled_int_part) : shift_left(taylor, scaled_int_part); - } - /** Calculate the inverse square root of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Inverse square root value of operand - */ - template - static fixed_point inv_sqrt(fixed_point x) - { - const uint8_t p = x.precision(); - int8_t shift = std::numeric_limits::digits - (p + detail::clz(x.raw())); - - shift += std::numeric_limits::is_signed ? 1 : 0; - - // Use volatile to restrict compiler optimizations on shift as compiler reports maybe-uninitialized error on Android - volatile int8_t *shift_ptr = &shift; - - auto const_three = fixed_point(3, p); - auto a = (*shift_ptr < 0) ? shift_left(x, -(shift)) : shift_right(x, shift); - fixed_point x2 = a; - - // We need three iterations to find the result for QS8 and five for QS16 - constexpr int num_iterations = std::is_same::value ? 3 : 5; - for(int i = 0; i < num_iterations; ++i) - { - fixed_point three_minus_dx = sub(const_three, mul(a, mul(x2, x2))); - x2 = shift_right(mul(x2, three_minus_dx), 1); - } - - return (shift < 0) ? shift_left(x2, (-shift) >> 1) : shift_right(x2, shift >> 1); - } - /** Calculate the hyperbolic tangent of a fixed point number - * - * @param[in] x Fixed point operand - * - * @return Hyperbolic tangent of the operand - */ - template - static fixed_point tanh(fixed_point x) - { - uint8_t p = x.precision(); - // Constants - auto const_one = fixed_point(1, p); - auto const_two = fixed_point(2, p); - - auto exp2x = exp(const_two * x); - auto num = exp2x - const_one; - auto den = exp2x + const_one; - auto tanh = num / den; - - return tanh; - } - /** Calculate the a-th power of a fixed point number. - * - * The power is computed as x^a = e^(log(x) * a) - * - * @param[in] x Fixed point operand - * @param[in] a Fixed point exponent - * - * @return a-th power of the operand - */ - template - static fixed_point pow(fixed_point x, fixed_point a) - { - return exp(log(x) * a); - } -}; - -template -bool operator==(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::isequal(lhs, rhs); -} -template -bool operator!=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator==(lhs, rhs); -} -template -bool operator<(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::isless(lhs, rhs); -} -template -bool operator>(const fixed_point &lhs, const fixed_point &rhs) -{ - return operator<(rhs, lhs); -} -template -bool operator<=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator>(lhs, rhs); -} -template -bool operator>=(const fixed_point &lhs, const fixed_point &rhs) -{ - return !operator<(lhs, rhs); -} -template -fixed_point operator+(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::add(lhs, rhs); -} -template -fixed_point operator-(const fixed_point &lhs, const fixed_point &rhs) -{ - return functions::sub(lhs, rhs); -} -template -fixed_point operator-(const fixed_point &rhs) -{ - return functions::negate(rhs); -} -template -fixed_point operator*(fixed_point x, fixed_point y) -{ - return functions::mul(x, y); -} -template -fixed_point operator/(fixed_point x, fixed_point y) -{ - return functions::div(x, y); -} -template -fixed_point operator>>(fixed_point x, size_t shift) -{ - return functions::shift_right(x, shift); -} -template -fixed_point operator<<(fixed_point x, size_t shift) -{ - return functions::shift_left(x, shift); -} -template -std::basic_ostream &operator<<(std::basic_ostream &s, fixed_point x) -{ - return functions::write(s, x); -} -template -inline fixed_point min(fixed_point x, fixed_point y) -{ - return x > y ? y : x; -} -template -inline fixed_point max(fixed_point x, fixed_point y) -{ - return x > y ? x : y; -} -template -inline fixed_point add(fixed_point x, fixed_point y) -{ - return functions::add(x, y); -} -template -inline fixed_point sub(fixed_point x, fixed_point y) -{ - return functions::sub(x, y); -} -template -inline fixed_point mul(fixed_point x, fixed_point y) -{ - return functions::mul(x, y); -} -template -inline fixed_point div(fixed_point x, fixed_point y) -{ - return functions::div(x, y); -} -template -inline fixed_point abs(fixed_point x) -{ - return functions::abs(x); -} -template -inline fixed_point clamp(fixed_point x, T min, T max) -{ - return functions::clamp(x, min, max); -} -template -inline fixed_point exp(fixed_point x) -{ - return functions::exp(x); -} -template -inline fixed_point log(fixed_point x) -{ - return functions::log(x); -} -template -inline fixed_point inv_sqrt(fixed_point x) -{ - return functions::inv_sqrt(x); -} -template -inline fixed_point tanh(fixed_point x) -{ - return functions::tanh(x); -} -template -inline fixed_point pow(fixed_point x, fixed_point a) -{ - return functions::pow(x, a); -} -} // namespace detail - -// Expose operators -using detail::operator==; -using detail::operator!=; -using detail::operator<; -using detail::operator>; -using detail::operator<=; -using detail::operator>=; -using detail::operator+; -using detail::operator-; -using detail::operator*; -using detail::operator/; -using detail::operator>>; -using detail::operator<<; - -// Expose additional functions -using detail::min; -using detail::max; -using detail::add; -using detail::sub; -using detail::mul; -using detail::div; -using detail::abs; -using detail::clamp; -using detail::exp; -using detail::log; -using detail::inv_sqrt; -using detail::tanh; -using detail::pow; -// TODO: floor -// TODO: ceil -// TODO: sqrt -} // namespace fixed_point_arithmetic -} // namespace test -} // namespace arm_compute -#endif /*__ARM_COMPUTE_TEST_VALIDATION_FIXEDPOINT_H__ */ diff --git a/tests/validation_new/Helpers.cpp b/tests/validation_new/Helpers.cpp deleted file mode 100644 index c65966b06f..0000000000 --- a/tests/validation_new/Helpers.cpp +++ /dev/null @@ -1,57 +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 "tests/validation_new/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes) -{ - ARM_COMPUTE_ERROR_ON(input_shapes.empty()); - - TensorShape out_shape = input_shapes[0]; - - size_t max_x = 0; - size_t max_y = 0; - size_t depth = 0; - - for(const auto &shape : input_shapes) - { - max_x = std::max(shape.x(), max_x); - max_y = std::max(shape.y(), max_y); - depth += shape.z(); - } - - out_shape.set(0, max_x); - out_shape.set(1, max_y); - out_shape.set(2, depth); - - return out_shape; -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Helpers.h b/tests/validation_new/Helpers.h deleted file mode 100644 index 30959161bb..0000000000 --- a/tests/validation_new/Helpers.h +++ /dev/null @@ -1,142 +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. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ - -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "tests/validation/half.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -struct is_floating_point : public std::is_floating_point -{ -}; - -template <> -struct is_floating_point : public std::true_type -{ -}; - -/** Helper function to get the testing range for each activation layer. - * - * @param[in] activation Activation function to test. - * @param[in] data_type Data type. - * @param[in] fixed_point_position Number of bits for the fractional part. Defaults to 1. - * - * @return A pair containing the lower upper testing bounds for a given function. - */ -template -std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, DataType data_type, int fixed_point_position = 0) -{ - std::pair bounds; - - switch(data_type) - { - case DataType::F16: - { - using namespace half_float::literal; - - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::SQUARE: - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - bounds = std::make_pair(-10._h, 10._h); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds = std::make_pair(0._h, 255._h); - break; - default: - bounds = std::make_pair(-255._h, 255._h); - break; - } - break; - } - case DataType::F32: - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - bounds = std::make_pair(-40.f, 40.f); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds = std::make_pair(0.f, 255.f); - break; - default: - bounds = std::make_pair(-255.f, 255.f); - break; - } - break; - case DataType::QS8: - case DataType::QS16: - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::TANH: - // Reduce range as exponent overflows - bounds = std::make_pair(-(1 << fixed_point_position), 1 << fixed_point_position); - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - // Can't be zero either as inv_sqrt is used in NEON. - bounds = std::make_pair(1, std::numeric_limits::max()); - break; - default: - bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); - break; - } - break; - default: - ARM_COMPUTE_ERROR("Unsupported data type"); - } - - return bounds; -} - -/** Calculate output tensor shape give a vector of input tensor to concatenate - * - * @param[in] input_shapes Shapes of the tensors to concatenate across depth. - * - * @return The shape of output concatenated tensor. - */ -TensorShape calculate_depth_concatenate_shape(const std::vector &input_shapes); -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ */ diff --git a/tests/validation_new/NEON/ActivationLayer.cpp b/tests/validation_new/NEON/ActivationLayer.cpp deleted file mode 100644 index bc2fe603fd..0000000000 --- a/tests/validation_new/NEON/ActivationLayer.cpp +++ /dev/null @@ -1,230 +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 "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 "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ActivationFunctionsDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ActivationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Define tolerance of the activation layer. - * - * @param[in] data_type The data type used. - * @param[in] activation The activation function used. - * - * @return Tolerance depending on the activation function. - */ -AbsoluteTolerance tolerance(DataType data_type, ActivationLayerInfo::ActivationFunction activation) -{ - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - case ActivationLayerInfo::ActivationFunction::SQRT: - case ActivationLayerInfo::ActivationFunction::TANH: - switch(data_type) - { - case DataType::QS8: - return AbsoluteTolerance(5.f); - case DataType::QS16: - return AbsoluteTolerance(11.f); - case DataType::F16: - return AbsoluteTolerance(0.01f); - default: - return AbsoluteTolerance(0.00001f); - } - break; - default: - return AbsoluteTolerance(0.f); - } -} - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -/** Input data sets. */ -const auto ActivationDataset = combine(combine(framework::dataset::make("InPlace", { false, true }), datasets::ActivationFunctions()), framework::dataset::make("AlphaBeta", { 0.5f, 1.f })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ActivationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), framework::dataset::make("InPlace", { false, true })), - shape, data_type, in_place) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // 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); - } -} - -template -using NEActivationLayerFixture = ActivationValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), ActivationDataset), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEActivationLayerFixedPointFixture = ActivationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [3,5] because [1,2] and [6,7] ranges cause -// overflowing issues in most of the transcendentals functions. -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 3, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NEActivationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEActivationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), ActivationDataset), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance(_data_type, _function)); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseAnd.cpp b/tests/validation_new/NEON/BitwiseAnd.cpp deleted file mode 100644 index 5e6f9000e2..0000000000 --- a/tests/validation_new/NEON/BitwiseAnd.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseAnd.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseAndFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseAnd) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseAnd bitwise_and; - bitwise_and.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseAndFixture = BitwiseAndValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseAndFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseAndFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseNot.cpp b/tests/validation_new/NEON/BitwiseNot.cpp deleted file mode 100644 index 3725379404..0000000000 --- a/tests/validation_new/NEON/BitwiseNot.cpp +++ /dev/null @@ -1,90 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseNot.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseNotFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseNot) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseNot bitwise_not; - bitwise_not.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseNotFixture = BitwiseNotValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseNotFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseNotFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseOr.cpp b/tests/validation_new/NEON/BitwiseOr.cpp deleted file mode 100644 index 84ddf8ea47..0000000000 --- a/tests/validation_new/NEON/BitwiseOr.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseOr.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseOrFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseOr) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseOr bitwise_or; - bitwise_or.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseOrFixture = BitwiseOrValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseOrFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseOrFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/BitwiseXor.cpp b/tests/validation_new/NEON/BitwiseXor.cpp deleted file mode 100644 index 5a5a650295..0000000000 --- a/tests/validation_new/NEON/BitwiseXor.cpp +++ /dev/null @@ -1,94 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEBitwiseXor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/BitwiseXorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(BitwiseXor) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src1 = create_tensor(shape, data_type); - Tensor src2 = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, data_type); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEBitwiseXor bitwise_xor; - bitwise_xor.configure(&src1, &src2, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src1.info()->valid_region(), valid_region); - validate(src2.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src1.info()->padding(), padding); - validate(src2.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEBitwiseXorFixture = BitwiseXorValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEBitwiseXorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEBitwiseXorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/ConvolutionLayer.cpp b/tests/validation_new/NEON/ConvolutionLayer.cpp deleted file mode 100644 index 1efff02428..0000000000 --- a/tests/validation_new/NEON/ConvolutionLayer.cpp +++ /dev/null @@ -1,192 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeConvolutionLayerDataset.h" -#include "tests/datasets_new/SmallConvolutionLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -const AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -const AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F16 */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -const AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ConvolutionLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallConvolutionLayerDataset(), datasets::LargeConvolutionLayerDataset()), CNNDataTypes), - input_shape, weights_shape, bias_shape, output_shape, info, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(input_shape, data_type, 1, fixed_point_position); - Tensor weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEConvolutionLayer conv; - conv.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(input_shape); - const ValidRegion weights_valid_region = shape_to_valid_region(weights_shape); - const ValidRegion bias_valid_region = shape_to_valid_region(bias_shape); - const ValidRegion dst_valid_region = shape_to_valid_region(output_shape); - - validate(src.info()->valid_region(), src_valid_region); - validate(weights.info()->valid_region(), weights_valid_region); - validate(bias.info()->valid_region(), bias_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - //TODO(COMPMID-415) Need to validate padding? -} - -template -using NEConvolutionLayerFixture = ConvolutionValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeConvolutionLayerDataset(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEConvolutionLayerFixedPointFixture = ConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) -FIXTURE_DATA_TEST_CASE(RunSmall, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEConvolutionLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeConvolutionLayerDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DepthConcatenateLayer.cpp b/tests/validation_new/NEON/DepthConcatenateLayer.cpp deleted file mode 100644 index d6400d2df5..0000000000 --- a/tests/validation_new/NEON/DepthConcatenateLayer.cpp +++ /dev/null @@ -1,125 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDepthConcatenate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DepthConcatenateLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(DepthConcatenateLayer) - -//TODO(COMPMID-415): Add configuration test? - -template -using NEDepthConcatenateLayerFixture = DepthConcatenateValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS8))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConcatenateLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConcatenateLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), - framework::dataset::make("DataType", - DataType::QS16))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DequantizationLayer.cpp b/tests/validation_new/NEON/DequantizationLayer.cpp deleted file mode 100644 index 8b67a14d12..0000000000 --- a/tests/validation_new/NEON/DequantizationLayer.cpp +++ /dev/null @@ -1,100 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDequantizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DequantizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(DequantizationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, DataType::F32); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - float min = 0.f; - float max = 0.f; - NEDequantizationLayer dequant_layer; - dequant_layer.configure(&src, &dst, &min, &max); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEDequantizationLayerFixture = DequantizationValidationFixture; - -TEST_SUITE(Integer) -TEST_SUITE(U8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEDequantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEDequantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::U8))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/DirectConvolutionLayer.cpp b/tests/validation_new/NEON/DirectConvolutionLayer.cpp deleted file mode 100644 index 68cbe54b32..0000000000 --- a/tests/validation_new/NEON/DirectConvolutionLayer.cpp +++ /dev/null @@ -1,149 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEDirectConvolutionLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/DirectConvolutionLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_qs(1.f); /**< Tolerance for fixed point tests */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_fp16(0.01f); /**< Tolerance for half precision floating point tests */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_fp32(0.001f); /**< Tolerance for floating point tests */ - -/** Direct convolution data set. */ -const auto data_pad_f32 = concat(concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", 3)))), - combine(framework::dataset::make("PadX", 0, 3), - combine(framework::dataset::make("PadY", 0, 3), - framework::dataset::make("KernelSize", 5)))); - -const auto data_pad_qs8 = concat(combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - framework::dataset::make("KernelSize", 1))), - combine(framework::dataset::make("PadX", 0, 2), - combine(framework::dataset::make("PadY", 0, 2), - framework::dataset::make("KernelSize", 3)))); - -const auto data_f32 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(data_pad_f32, - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -const auto data_qs8 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(data_pad_qs8, - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))); - -/** Direct convolution QS16 data set. */ -const auto data_qs16 = combine(datasets::SmallDirectConvolutionShapes(), - combine(framework::dataset::make("StrideX", 1, 3), - combine(framework::dataset::make("StrideY", 1, 3), - combine(framework::dataset::make("PadX", 0), - combine(framework::dataset::make("PadY", 0), - combine(framework::dataset::make("KernelSize", 1), - framework::dataset::make("NumKernels", { 1, 4, 8, 16 }))))))); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(DirectConvolutionLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using NEDirectConvolutionLayerFixture = DirectConvolutionValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fp16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixture, framework::DatasetMode::ALL, combine(data_f32, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fp32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEDirectConvolutionLayerFixedPointFixture = DirectConvolutionValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// We test for fixed point precision [4,6] -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs8, framework::dataset::make("DataType", DataType::QS8)), - framework::dataset::make("FractionalBits", 4, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// We test for fixed point precision [4,13] -FIXTURE_DATA_TEST_CASE(Run, NEDirectConvolutionLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(data_qs16, framework::dataset::make("DataType", DataType::QS16)), - framework::dataset::make("FractionalBits", 4, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/Floor.cpp b/tests/validation_new/NEON/Floor.cpp deleted file mode 100644 index e100c3035b..0000000000 --- a/tests/validation_new/NEON/Floor.cpp +++ /dev/null @@ -1,66 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFloor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FloorFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(Floor) - -template -using NEFloorFixture = FloorValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFloorFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFloorFixture, framework::DatasetMode::NIGHTLY, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/FullyConnectedLayer.cpp b/tests/validation_new/NEON/FullyConnectedLayer.cpp deleted file mode 100644 index e859fb3872..0000000000 --- a/tests/validation_new/NEON/FullyConnectedLayer.cpp +++ /dev/null @@ -1,211 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/FullyConnectedLayerDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/FullyConnectedLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.001f); -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.01f); -#endif /* ARM_COMPUTE_ENABLE_FP16*/ -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(1.f); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); - -const auto FullyConnectedParameters = combine(framework::dataset::make("TransposeWeights", { false, true }), framework::dataset::make("ReshapeWeights", { false, true })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(FullyConnectedLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(framework::dataset::concat(datasets::SmallFullyConnectedLayerDataset(), datasets::LargeFullyConnectedLayerDataset()), - FullyConnectedParameters), - CNNDataTypes), - src_shape, weights_shape, bias_shape, dst_shape, transpose_weights, reshape_weights, data_type) -{ - // Set fixed point position data type allowed - int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - TensorShape ws(weights_shape); - - // Transpose weights if not done in the function - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = ws.x(); - ws.set(0, ws.y()); - ws.set(1, shape_x); - - // Weights have to be passed reshaped - // Transpose 1xW for batched version - if(!reshape_weights && dst_shape.y() > 1) - { - const float transpose_width = 16.0f / data_size_from_type(data_type); - const size_t shape_x = ws.x(); - ws.set(0, ws.y() * static_cast(transpose_width)); - ws.set(1, static_cast(std::ceil(shape_x / transpose_width))); - } - } - - // Create tensors - Tensor src = create_tensor(src_shape, data_type, 1, fixed_point_position); - Tensor weights = create_tensor(ws, data_type, 1, fixed_point_position); - Tensor bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - NEFullyConnectedLayer fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using NEFullyConnectedLayerFixture = FullyConnectedLayerValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeFullyConnectedLayerDataset(), FullyConnectedParameters), - framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEFullyConnectedLayerFixedPointFixture = FullyConnectedLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEFullyConnectedLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeFullyConnectedLayerDataset(), - FullyConnectedParameters), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/GEMM.cpp b/tests/validation_new/NEON/GEMM.cpp deleted file mode 100644 index 453b183d1e..0000000000 --- a/tests/validation_new/NEON/GEMM.cpp +++ /dev/null @@ -1,170 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/LargeGEMMDataset.h" -#include "tests/datasets_new/SmallGEMMDataset.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/GEMMFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance tolerance_f(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for floating point data types */ -constexpr AbsoluteTolerance tolerance_q(1.0f); /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(GEMM) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMDataset(), datasets::LargeGEMMDataset()), CNNDataTypes), - shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor a = create_tensor(shape_a, data_type, 1, fixed_point_position); - Tensor b = create_tensor(shape_b, data_type, 1, fixed_point_position); - Tensor c = create_tensor(shape_c, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEGEMM gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - //TODO(COMPMID-415): Validate valid region -} - -template -using NEGEMMFixture = GEMMValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", - DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMDataset(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NEGEMMFixedPointFixture = GEMMValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 7))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeGEMMDataset(), - framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_q); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/L2Normalize.cpp b/tests/validation_new/NEON/L2Normalize.cpp deleted file mode 100644 index 20804d2a94..0000000000 --- a/tests/validation_new/NEON/L2Normalize.cpp +++ /dev/null @@ -1,75 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEL2Normalize.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/L2NormalizeFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(L2Normalize) - -template -using NEL2NormalizeFixture = L2NormalizeValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEL2NormalizeFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, NEL2NormalizeFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), framework::dataset::make("Epsilon", { 1e-12 }))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/MeanStdDev.cpp b/tests/validation_new/NEON/MeanStdDev.cpp deleted file mode 100644 index 6214261afb..0000000000 --- a/tests/validation_new/NEON/MeanStdDev.cpp +++ /dev/null @@ -1,93 +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 "arm_compute/runtime/NEON/functions/NEMeanStdDev.h" -#include "framework/Macros.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/MeanStdDevFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr RelativeTolerance tolerance_rel_high_error(0.05f); -constexpr RelativeTolerance tolerance_rel_low_error(0.0005f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(MeanStdDev) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::U8)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.f; - float std_dev = 0.f; - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create configure function - NEMeanStdDev mean_std_dev_image; - mean_std_dev_image.configure(&src, &mean, &std_dev); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); - validate(src.info()->padding(), padding); -} - -template -using NEMeanStdDevFixture = MeanStdDevValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEMeanStdDevFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEMeanStdDevFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", - DataType::U8))) -{ - // Validate mean output - validate(_target.first, _reference.first, tolerance_rel_low_error); - - // Validate std_dev output - validate(_target.second, _reference.second, tolerance_rel_high_error); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/NormalizationLayer.cpp b/tests/validation_new/NEON/NormalizationLayer.cpp deleted file mode 100644 index 1da2ed0874..0000000000 --- a/tests/validation_new/NEON/NormalizationLayer.cpp +++ /dev/null @@ -1,144 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/NormalizationTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/NormalizationLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.001f); -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_f32(0.00001f); -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_qs8(2); -constexpr AbsoluteTolerance tolerance_qs16(3); - -/** Input data set. */ -const auto NormalizationDataset = combine(combine(combine(datasets::SmallShapes(), datasets::NormalizationTypes()), framework::dataset::make("NormalizationSize", 3, 9, 2)), - framework::dataset::make("Beta", { 0.5f, 1.f, 2.f })); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(NormalizationLayer) - -//TODO(COMPMID-415): Missing configuration? - -template -using NENormalizationLayerFixture = NormalizationValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(NormalizationDataset, framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NENormalizationLayerFixedPointFixture = NormalizationValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NENormalizationLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NENormalizationLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(NormalizationDataset, framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/PoolingLayer.cpp b/tests/validation_new/NEON/PoolingLayer.cpp deleted file mode 100644 index 20fce3d73a..0000000000 --- a/tests/validation_new/NEON/PoolingLayer.cpp +++ /dev/null @@ -1,148 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/PoolingTypesDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/PoolingLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Input data set for float data types */ -const auto PoolingLayerDatasetFP = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3, 7 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -/** Input data set for quantized data types */ -const auto PoolingLayerDatasetQS = combine(combine(datasets::PoolingTypes(), framework::dataset::make("PoolingSize", { 2, 3 })), - framework::dataset::make("PadStride", { PadStrideInfo(1, 1, 0, 0), PadStrideInfo(2, 1, 0, 0), PadStrideInfo(1, 2, 1, 1), PadStrideInfo(2, 2, 1, 0) })); - -constexpr AbsoluteTolerance tolerance_f32(0.001f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.01f); /**< Tolerance value for comparing reference's output against implementation's output for float types */ -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -constexpr AbsoluteTolerance tolerance_qs8(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -constexpr AbsoluteTolerance tolerance_qs16(0); /**< Tolerance value for comparing reference's output against implementation's output for quantized input */ -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(PoolingLayer) - -//TODO(COMPMID-415): Configuration tests? - -template -using NEPoolingLayerFixture = PoolingLayerValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, framework::dataset::make("DataType", - DataType::F32)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixture, framework::DatasetMode::ALL, combine(datasets::SmallShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), combine(PoolingLayerDatasetFP, - framework::dataset::make("DataType", DataType::F16)))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ -TEST_SUITE_END() - -template -using NEPoolingLayerFixedPointFixture = PoolingLayerValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 5))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS8))), - framework::dataset::make("FractionalBits", 1, 5))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs8); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -FIXTURE_DATA_TEST_CASE(RunSmall, NEPoolingLayerFixedPointFixture, framework::DatasetMode::ALL, combine(combine(datasets::SmallShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 13))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEPoolingLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), combine(PoolingLayerDatasetQS, - framework::dataset::make("DataType", DataType::QS16))), - framework::dataset::make("FractionalBits", 1, 13))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_qs16); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/QuantizationLayer.cpp b/tests/validation_new/NEON/QuantizationLayer.cpp deleted file mode 100644 index 8b2acd6331..0000000000 --- a/tests/validation_new/NEON/QuantizationLayer.cpp +++ /dev/null @@ -1,98 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEQuantizationLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/QuantizationLayerFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for quantization */ -constexpr AbsoluteTolerance tolerance_u8(1); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(QuantizationLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("DataType", DataType::F32)), shape, data_type) -{ - // Create tensors - Tensor src = create_tensor(shape, data_type); - Tensor dst = create_tensor(shape, DataType::U8); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEQuantizationLayer quant_layer; - quant_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const PaddingSize padding = PaddingCalculator(shape.x(), 8).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NEQuantizationLayerFixture = QuantizationValidationFixture; - -TEST_SUITE(Float) -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEQuantizationLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_u8); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEQuantizationLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_u8); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/ReductionOperation.cpp b/tests/validation_new/NEON/ReductionOperation.cpp deleted file mode 100644 index 4048af09e7..0000000000 --- a/tests/validation_new/NEON/ReductionOperation.cpp +++ /dev/null @@ -1,75 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEReductionOperation.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ReductionOperationDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ReductionOperationFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr RelativeTolerance tolerance_f32(0.00001f); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(ReductionOperation) - -template -using NEReductionOperationFixture = ReductionOperationValidationFixture; - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NEReductionOperationFixture, framework::DatasetMode::PRECOMMIT, - combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEReductionOperationFixture, framework::DatasetMode::NIGHTLY, - combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32)), framework::dataset::make("Axis", { 0 })), datasets::ReductionOperations())) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/Scale.cpp b/tests/validation_new/NEON/Scale.cpp deleted file mode 100644 index 1036f98c23..0000000000 --- a/tests/validation_new/NEON/Scale.cpp +++ /dev/null @@ -1,127 +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 "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEScale.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/BorderModeDataset.h" -#include "tests/datasets_new/InterpolationPolicyDataset.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/ScaleFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -TEST_SUITE(NEON) -TEST_SUITE(Scale) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(combine(combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), framework::dataset::make("DataType", DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes()), - shape, data_type, policy, border_mode) -{ - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 2); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - uint8_t constant_border_value = 0; - if(border_mode == BorderMode::CONSTANT) - { - std::uniform_int_distribution distribution_u8(0, 255); - constant_border_value = distribution_u8(generator); - } - - // Create tensors - Tensor src = create_tensor(shape, data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - Tensor dst = create_tensor(shape_scaled, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NEScale nescale; - nescale.configure(&src, &dst, policy, border_mode, constant_border_value); - - // Validate valid region - const ValidRegion dst_valid_region = calculate_valid_region_scale(*(src.info()), shape_scaled, policy, BorderSize(1), (border_mode == BorderMode::UNDEFINED)); - - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape_scaled.x(), 16); - calculator.set_border_mode(border_mode); - - const PaddingSize read_padding(1); - const PaddingSize write_padding = calculator.required_padding(PaddingCalculator::Option::EXCLUDE_BORDER); - validate(src.info()->padding(), read_padding); - validate(dst.info()->padding(), write_padding); -} - -template -using NEScaleFixture = ScaleValidationFixture; - -FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(Accessor(_target), _reference, valid_region); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NEScaleFixture, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::U8)), - framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR })), - datasets::BorderModes())) -{ - //Create valid region - TensorInfo src_info(_shape, 1, _data_type); - ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, BorderSize(1), (_border_mode == BorderMode::UNDEFINED)); - - // Validate output - validate(Accessor(_target), _reference, valid_region); -} - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/NEON/SoftmaxLayer.cpp b/tests/validation_new/NEON/SoftmaxLayer.cpp deleted file mode 100644 index 337ee29986..0000000000 --- a/tests/validation_new/NEON/SoftmaxLayer.cpp +++ /dev/null @@ -1,175 +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 "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "framework/Asserts.h" -#include "framework/Macros.h" -#include "framework/datasets/Datasets.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets_new/ShapeDatasets.h" -#include "tests/validation_new/Validation.h" -#include "tests/validation_new/fixtures/SoftmaxLayerFixture.h" -#include "tests/validation_new/half.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Tolerance for float operations */ -constexpr AbsoluteTolerance tolerance_f32(0.000001f); -#ifdef ARM_COMPUTE_ENABLE_FP16 -constexpr AbsoluteTolerance tolerance_f16(0.0001f); -#endif /* ARM_COMPUTE_ENABLE_FP16*/ -/** Tolerance for fixed point operations */ -constexpr AbsoluteTolerance tolerance_fixed_point(2); - -/** CNN data types */ -const auto CNNDataTypes = framework::dataset::make("DataType", -{ -#ifdef ARM_COMPUTE_ENABLE_FP16 - DataType::F16, -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - DataType::F32, - DataType::QS8, - DataType::QS16, -}); -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(SoftmaxLayer) - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(concat(datasets::SmallShapes(), datasets::LargeShapes()), CNNDataTypes), shape, data_type) -{ - // Set fixed point position data type allowed - const int fixed_point_position = is_data_type_fixed_point(data_type) ? 3 : 0; - - // Create tensors - Tensor src = create_tensor(shape, data_type, 1, fixed_point_position); - Tensor dst = create_tensor(shape, data_type, 1, fixed_point_position); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function - NESoftmaxLayer smx_layer; - smx_layer.configure(&src, &dst); - - // Validate valid region - const ValidRegion valid_region = shape_to_valid_region(shape); - validate(src.info()->valid_region(), valid_region); - validate(dst.info()->valid_region(), valid_region); - - // Validate padding - const int step = 16 / data_size_from_type(data_type); - const PaddingSize padding = PaddingCalculator(shape.x(), step).required_padding(); - validate(src.info()->padding(), padding); - validate(dst.info()->padding(), padding); -} - -template -using NESoftmaxLayerFixture = SoftmaxValidationFixture; - -TEST_SUITE(Float) -#ifdef ARM_COMPUTE_ENABLE_FP16 -TEST_SUITE(FP16) -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F16))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f16); -} -TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -TEST_SUITE(FP32) -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), framework::dataset::make("DataType", DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() - -template -using NESoftmaxLayerFixedPointFixture = SoftmaxValidationFixedPointFixture; - -TEST_SUITE(Quantized) -TEST_SUITE(QS8) -// Testing for fixed point position [1,6) as reciprocal limits the maximum fixed point position to 5 -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS8)), - framework::dataset::make("FractionalBits", 1, 6))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() - -TEST_SUITE(QS16) -// Testing for fixed point position [1,14) as reciprocal limits the maximum fixed point position to 14 -FIXTURE_DATA_TEST_CASE(RunSmall, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -FIXTURE_DATA_TEST_CASE(RunLarge, NESoftmaxLayerFixedPointFixture, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType", - DataType::QS16)), - framework::dataset::make("FractionalBits", 1, 14))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_fixed_point); -} -TEST_SUITE_END() -TEST_SUITE_END() - -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Validation.cpp b/tests/validation_new/Validation.cpp deleted file mode 100644 index fec7c10939..0000000000 --- a/tests/validation_new/Validation.cpp +++ /dev/null @@ -1,307 +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 "Validation.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/Tensor.h" -#include "tests/validation/half.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -/** Get the data from *ptr after casting according to @p data_type and then convert the data to double. - * - * @param[in] ptr Pointer to value. - * @param[in] data_type Data type of both values. - * - * @return The data from the ptr after converted to double. - */ -double get_double_data(const void *ptr, DataType data_type) -{ - if(ptr == nullptr) - { - ARM_COMPUTE_ERROR("Can't dereference a null pointer!"); - } - - switch(data_type) - { - case DataType::U8: - return *reinterpret_cast(ptr); - case DataType::S8: - return *reinterpret_cast(ptr); - case DataType::QS8: - return *reinterpret_cast(ptr); - case DataType::U16: - return *reinterpret_cast(ptr); - case DataType::S16: - return *reinterpret_cast(ptr); - case DataType::QS16: - return *reinterpret_cast(ptr); - case DataType::U32: - return *reinterpret_cast(ptr); - case DataType::S32: - return *reinterpret_cast(ptr); - case DataType::U64: - return *reinterpret_cast(ptr); - case DataType::S64: - return *reinterpret_cast(ptr); - case DataType::F16: - return *reinterpret_cast(ptr); - case DataType::F32: - return *reinterpret_cast(ptr); - case DataType::F64: - return *reinterpret_cast(ptr); - case DataType::SIZET: - return *reinterpret_cast(ptr); - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } -} - -void check_border_element(const IAccessor &tensor, const Coordinates &id, - const BorderMode &border_mode, const void *border_value, - int64_t &num_elements, int64_t &num_mismatches) -{ - const size_t channel_size = element_size_from_data_type(tensor.data_type()); - const auto ptr = static_cast(tensor(id)); - - if(border_mode == BorderMode::REPLICATE) - { - Coordinates border_id{ id }; - - if(id.x() < 0) - { - border_id.set(0, 0); - } - else if(static_cast(id.x()) >= tensor.shape().x()) - { - border_id.set(0, tensor.shape().x() - 1); - } - - if(id.y() < 0) - { - border_id.set(1, 0); - } - else if(static_cast(id.y()) >= tensor.shape().y()) - { - border_id.set(1, tensor.shape().y() - 1); - } - - border_value = tensor(border_id); - } - - // Iterate over all channels within one element - for(int channel = 0; channel < tensor.num_channels(); ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double reference = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); - - if(!compare, double>(target, reference)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << channel); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); - ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } -} -} // namespace - -void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) -{ - ARM_COMPUTE_EXPECT_EQUAL(region.anchor.num_dimensions(), reference.anchor.num_dimensions(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(region.shape.num_dimensions(), reference.shape.num_dimensions(), framework::LogLevel::ERRORS); - - for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) - { - ARM_COMPUTE_EXPECT_EQUAL(region.anchor[d], reference.anchor[d], framework::LogLevel::ERRORS); - } - - for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) - { - ARM_COMPUTE_EXPECT_EQUAL(region.shape[d], reference.shape[d], framework::LogLevel::ERRORS); - } -} - -void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) -{ - ARM_COMPUTE_EXPECT_EQUAL(padding.top, reference.top, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.right, reference.right, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.bottom, reference.bottom, framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(padding.left, reference.left, framework::LogLevel::ERRORS); -} - -void validate(const IAccessor &tensor, const void *reference_value) -{ - ARM_COMPUTE_ASSERT(reference_value != nullptr); - - int64_t num_mismatches = 0; - int64_t num_elements = 0; - const size_t channel_size = element_size_from_data_type(tensor.data_type()); - - // Iterate over all elements, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < tensor.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(tensor.shape(), element_idx); - - const auto ptr = static_cast(tensor(id)); - - // Iterate over all channels within one element - for(int channel = 0; channel < tensor.num_channels(); ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, tensor.data_type()); - const double reference = get_double_data(reference_value, tensor.data_type()); - - if(!compare, double>(target, reference)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << channel); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << target); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << reference); - ARM_COMPUTE_EXPECT_EQUAL(target, reference, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } - } - - if(num_elements > 0) - { - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); - } -} - -void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value) -{ - if(border_mode == BorderMode::UNDEFINED) - { - return; - } - else if(border_mode == BorderMode::CONSTANT) - { - ARM_COMPUTE_ASSERT(border_value != nullptr); - } - - int64_t num_mismatches = 0; - int64_t num_elements = 0; - const int slice_size = tensor.shape()[0] * tensor.shape()[1]; - - for(int element_idx = 0; element_idx < tensor.num_elements(); element_idx += slice_size) - { - Coordinates id = index2coord(tensor.shape(), element_idx); - - // Top border - for(int y = -border_size.top; y < 0; ++y) - { - id.set(1, y); - - for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - - // Bottom border - for(int y = tensor.shape()[1]; y < static_cast(tensor.shape()[1]) + static_cast(border_size.bottom); ++y) - { - id.set(1, y); - - for(int x = -border_size.left; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - - // Left/right border - for(int y = 0; y < static_cast(tensor.shape()[1]); ++y) - { - id.set(1, y); - - // Left border - for(int x = -border_size.left; x < 0; ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - - // Right border - for(int x = tensor.shape()[0]; x < static_cast(tensor.shape()[0]) + static_cast(border_size.right); ++x) - { - id.set(0, x); - - check_border_element(tensor, id, border_mode, border_value, num_elements, num_mismatches); - } - } - } - - if(num_elements > 0) - { - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches << "%) mismatched"); - ARM_COMPUTE_EXPECT_EQUAL(num_mismatches, 0, framework::LogLevel::ERRORS); - } -} - -void validate(std::vector classified_labels, std::vector expected_labels) -{ - ARM_COMPUTE_EXPECT_EQUAL(classified_labels.size(), expected_labels.size(), framework::LogLevel::ERRORS); - - for(unsigned int i = 0; i < expected_labels.size(); ++i) - { - ARM_COMPUTE_EXPECT_EQUAL(classified_labels[i], expected_labels[i], framework::LogLevel::ERRORS); - } -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/Validation.h b/tests/validation_new/Validation.h deleted file mode 100644 index d3c3541982..0000000000 --- a/tests/validation_new/Validation.h +++ /dev/null @@ -1,351 +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. - */ -#ifndef __ARM_COMPUTE_TEST_VALIDATION_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_H__ - -#include "SimpleTensor.h" -#include "arm_compute/core/FixedPoint.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Exceptions.h" -#include "tests/IAccessor.h" -#include "tests/TypePrinter.h" -#include "tests/Utils.h" - -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Class reprensenting an absolute tolerance value. */ -template -class AbsoluteTolerance -{ -public: - /** Underlying type. */ - using value_type = T; - - /* Default constructor. - * - * Initialises the tolerance to 0. - */ - AbsoluteTolerance() = default; - - /** Constructor. - * - * @param[in] value Absolute tolerance value. - */ - explicit constexpr AbsoluteTolerance(T value) - : _value{ value } - { - } - - /** Implicit conversion to the underlying type. */ - constexpr operator T() const - { - return _value; - } - -private: - T _value{ std::numeric_limits::epsilon() }; -}; - -/** Class reprensenting a relative tolerance value. */ -class RelativeTolerance -{ -public: - /** Underlying type. */ - using value_type = double; - - /* Default constructor. - * - * Initialises the tolerance to 0. - */ - RelativeTolerance() = default; - - /** Constructor. - * - * @param[in] value Relative tolerance value. - */ - explicit constexpr RelativeTolerance(value_type value) - : _value{ value } - { - } - - /** Implicit conversion to the underlying type. */ - constexpr operator value_type() const - { - return _value; - } - -private: - value_type _value{ 0 }; -}; - -/** Print AbsoluteTolerance type. */ -template -inline ::std::ostream &operator<<(::std::ostream &os, const AbsoluteTolerance &tolerance) -{ - os << static_cast::value_type>(tolerance); - - return os; -} - -/** Print RelativeTolerance type. */ -inline ::std::ostream &operator<<(::std::ostream &os, const RelativeTolerance &tolerance) -{ - os << static_cast(tolerance); - - return os; -} - -template -bool compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) -{ - if(dimensions1.num_dimensions() != dimensions2.num_dimensions()) - { - return false; - } - - for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i) - { - if(dimensions1[i] != dimensions2[i]) - { - return false; - } - } - - return true; -} - -/** Validate valid regions. - * - * - Dimensionality has to be the same. - * - Anchors have to match. - * - Shapes have to match. - */ -void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference); - -/** Validate padding. - * - * Padding on all sides has to be the same. - */ -void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference); - -/** Validate tensors. - * - * - Dimensionality has to be the same. - * - All values have to match. - * - * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to - * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between - * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by - * other test cases. - */ -template > -void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value = U(), float tolerance_number = 0.f); - -/** Validate tensors with valid region. - * - * - Dimensionality has to be the same. - * - All values have to match. - * - * @note: wrap_range allows cases where reference tensor rounds up to the wrapping point, causing it to wrap around to - * zero while the test tensor stays at wrapping point to pass. This may permit true erroneous cases (difference between - * reference tensor and test tensor is multiple of wrap_range), but such errors would be detected by - * other test cases. - */ -template > -void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value = U(), float tolerance_number = 0.f); - -/** Validate tensors against constant value. - * - * - All values have to match. - */ -void validate(const IAccessor &tensor, const void *reference_value); - -/** Validate border against a constant value. - * - * - All border values have to match the specified value if mode is CONSTANT. - * - All border values have to be replicated if mode is REPLICATE. - * - Nothing is validated for mode UNDEFINED. - */ -void validate(const IAccessor &tensor, BorderSize border_size, const BorderMode &border_mode, const void *border_value); - -/** Validate classified labels against expected ones. - * - * - All values should match - */ -void validate(std::vector classified_labels, std::vector expected_labels); - -/** Validate float value. - * - * - All values should match - */ -template -void validate(T target, T reference, U tolerance = AbsoluteTolerance()); - -template -struct compare_base -{ - compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0)) - : _target{ target }, _reference{ reference }, _tolerance{ tolerance } - { - } - - typename T::value_type _target{}; - typename T::value_type _reference{}; - T _tolerance{}; -}; - -template -struct compare; - -template -struct compare, U> : public compare_base> -{ - using compare_base>::compare_base; - - operator bool() const - { - if(!std::isfinite(this->_target) || !std::isfinite(this->_reference)) - { - return false; - } - else if(this->_target == this->_reference) - { - return true; - } - - return static_cast(std::abs(this->_target - this->_reference)) <= static_cast(this->_tolerance); - } -}; - -template -struct compare : public compare_base -{ - using compare_base::compare_base; - - operator bool() const - { - if(!std::isfinite(_target) || !std::isfinite(_reference)) - { - return false; - } - else if(_target == _reference) - { - return true; - } - - const double relative_change = std::abs(static_cast(_target - _reference)) / _reference; - - return relative_change <= _tolerance; - } -}; - -template -void validate(const IAccessor &tensor, const SimpleTensor &reference, U tolerance_value, float tolerance_number) -{ - // Validate with valid region covering the entire shape - validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number); -} - -template -void validate(const IAccessor &tensor, const SimpleTensor &reference, const ValidRegion &valid_region, U tolerance_value, float tolerance_number) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - ARM_COMPUTE_EXPECT_EQUAL(tensor.element_size(), reference.element_size(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT_EQUAL(tensor.data_type(), reference.data_type(), framework::LogLevel::ERRORS); - - if(reference.format() != Format::UNKNOWN) - { - ARM_COMPUTE_EXPECT_EQUAL(tensor.format(), reference.format(), framework::LogLevel::ERRORS); - } - - ARM_COMPUTE_EXPECT_EQUAL(tensor.num_channels(), reference.num_channels(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(compare_dimensions(tensor.shape(), reference.shape()), framework::LogLevel::ERRORS); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - - // Iterate over all elements within valid region, e.g. U8, S16, RGB888, ... - for(int element_idx = 0; element_idx < min_elements; ++element_idx) - { - const Coordinates id = index2coord(reference.shape(), element_idx); - - if(is_in_valid_region(valid_region, id)) - { - // Iterate over all channels within one element - for(int c = 0; c < min_channels; ++c) - { - const T &target_value = reinterpret_cast(tensor(id))[c]; - const T &reference_value = reinterpret_cast(reference(id))[c]; - - if(!compare(target_value, reference_value, tolerance_value)) - { - ARM_COMPUTE_TEST_INFO("id = " << id); - ARM_COMPUTE_TEST_INFO("channel = " << c); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target_value)); - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference_value)); - ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance_value))); - ARM_COMPUTE_EXPECT_EQUAL(target_value, reference_value, framework::LogLevel::DEBUG); - - ++num_mismatches; - } - - ++num_elements; - } - } - } - - if(num_elements > 0) - { - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - ARM_COMPUTE_TEST_INFO(num_mismatches << " values (" << std::fixed << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); - ARM_COMPUTE_EXPECT(num_mismatches <= absolute_tolerance_number, framework::LogLevel::ERRORS); - } -} - -template -void validate(T target, T reference, U tolerance) -{ - ARM_COMPUTE_TEST_INFO("reference = " << std::setprecision(5) << framework::make_printable(reference)); - ARM_COMPUTE_TEST_INFO("target = " << std::setprecision(5) << framework::make_printable(target)); - ARM_COMPUTE_TEST_INFO("tolerance = " << std::setprecision(5) << framework::make_printable(static_cast(tolerance))); - ARM_COMPUTE_EXPECT((compare(target, reference, tolerance)), framework::LogLevel::ERRORS); -} -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */ diff --git a/tests/validation_new/fixtures/ActivationLayerFixture.h b/tests/validation_new/fixtures/ActivationLayerFixture.h deleted file mode 100644 index bf0e7ba6ea..0000000000 --- a/tests/validation_new/fixtures/ActivationLayerFixture.h +++ /dev/null @@ -1,157 +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. - */ -#ifndef ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ActivationLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ActivationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - _function = function; - - ActivationLayerInfo info(function, alpha_beta, alpha_beta); - - _target = compute_target(shape, in_place, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(is_data_type_float(_data_type)) - { - float min_bound = 0; - float max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - else - { - int min_bound = 0; - int max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type, _fractional_bits); - std::uniform_int_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, bool in_place, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType act_layer; - - TensorType *dst_ptr = in_place ? &src : &dst; - - act_layer.configure(&src, dst_ptr, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - if(!in_place) - { - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - act_layer.run(); - - if(in_place) - { - return src; - } - else - { - return dst; - } - } - - SimpleTensor compute_reference(const TensorShape &shape, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::activation_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; - ActivationLayerInfo::ActivationFunction _function{}; -}; - -template -class ActivationValidationFixture : public ActivationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type) - { - ActivationValidationFixedPointFixture::setup(shape, in_place, function, alpha_beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseAndFixture.h b/tests/validation_new/fixtures/BitwiseAndFixture.h deleted file mode 100644 index 1769ecdb1f..0000000000 --- a/tests/validation_new/fixtures/BitwiseAndFixture.h +++ /dev/null @@ -1,113 +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. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseAnd.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseAndValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_and; - - bitwise_and.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_and.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_and(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseNotFixture.h b/tests/validation_new/fixtures/BitwiseNotFixture.h deleted file mode 100644 index 5954c8639e..0000000000 --- a/tests/validation_new/fixtures/BitwiseNotFixture.h +++ /dev/null @@ -1,106 +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. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseNot.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseNotValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_not; - - bitwise_not.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - bitwise_not.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::bitwise_not(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseOrFixture.h b/tests/validation_new/fixtures/BitwiseOrFixture.h deleted file mode 100644 index b39b46e813..0000000000 --- a/tests/validation_new/fixtures/BitwiseOrFixture.h +++ /dev/null @@ -1,113 +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. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseOr.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseOrValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_or; - - bitwise_or.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_or.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_or(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseXorFixture.h b/tests/validation_new/fixtures/BitwiseXorFixture.h deleted file mode 100644 index 1dfbf1f784..0000000000 --- a/tests/validation_new/fixtures/BitwiseXorFixture.h +++ /dev/null @@ -1,113 +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. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseXor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseXorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_xor; - - bitwise_xor.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_xor.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_xor(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/ConvolutionLayerFixture.h b/tests/validation_new/fixtures/ConvolutionLayerFixture.h deleted file mode 100644 index 25a53d0c1d..0000000000 --- a/tests/validation_new/fixtures/ConvolutionLayerFixture.h +++ /dev/null @@ -1,152 +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. - */ -#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ConvolutionValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType conv; - conv.configure(&src, &weights, &bias, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - fill(AccessorType(bias), 2); - - // Compute NEConvolutionLayer function - conv.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::convolution_layer(src, weights, bias, output_shape, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class ConvolutionValidationFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type) - { - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h b/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h deleted file mode 100644 index 601758f80e..0000000000 --- a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h +++ /dev/null @@ -1,177 +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. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthConcatenateLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -class ITensor; -class Tensor; -class ICLTensor; -class CLTensor; - -namespace test -{ -namespace validation -{ -template -class DepthConcatenateValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Create input shapes - std::mt19937 gen(library->seed()); - std::uniform_int_distribution<> num_dis(2, 6); - const int num_tensors = num_dis(gen); - - std::vector shapes(num_tensors, shape); - std::uniform_int_distribution<> depth_dis(1, 7); - std::bernoulli_distribution mutate_dis(0.25f); - std::uniform_real_distribution<> change_dis(-0.25f, 0.f); - - // Generate more shapes based on the input - for(auto &s : shapes) - { - // Set the depth of the tensor - s.set(2, depth_dis(gen)); - - // Randomly change the first dimension - if(mutate_dis(gen)) - { - // Decrease the dimension by a small percentage. Don't increase - // as that could make tensor too large. Also the change must be - // an even number. Otherwise out depth concatenate fails. - s.set(0, s[0] + 2 * static_cast(s[0] * change_dis(gen))); - } - - // Repeat the same as above for the second dimension - if(mutate_dis(gen)) - { - s.set(1, s[1] + 2 * static_cast(s[1] * change_dis(gen))); - } - } - - _target = compute_target(shapes, data_type); - _reference = compute_reference(shapes, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(std::vector shapes, DataType data_type) - { - using ITensorType = typename std::conditional::value, ITensor, ICLTensor>::type; - - std::vector srcs; - std::vector src_ptrs; - - // Create tensors - srcs.reserve(shapes.size()); - - for(const auto &shape : shapes) - { - srcs.emplace_back(create_tensor(shape, data_type, 1, _fractional_bits)); - src_ptrs.emplace_back(&srcs.back()); - } - - TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); - TensorType dst = create_tensor(dst_shape, data_type, 1, _fractional_bits); - - // Create and configure function - FunctionType depth_concat; - depth_concat.configure(src_ptrs, &dst); - - for(auto &src : srcs) - { - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - for(auto &src : srcs) - { - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - int i = 0; - for(auto &src : srcs) - { - fill(AccessorType(src), i++); - } - - // Compute function - depth_concat.run(); - - return dst; - } - - SimpleTensor compute_reference(std::vector shapes, DataType data_type) - { - std::vector> srcs; - - // Create and fill tensors - int i = 0; - for(const auto &shape : shapes) - { - srcs.emplace_back(shape, data_type, 1, _fractional_bits); - fill(srcs.back(), i++); - } - - return reference::depthconcatenate_layer(srcs); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - int _fractional_bits{ 1 }; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h b/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h deleted file mode 100644 index b745c7e53c..0000000000 --- a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h +++ /dev/null @@ -1,120 +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. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseConvolution.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape weights_shape, TensorShape out_shape, PadStrideInfo pad_stride_info) - { - _target = compute_target(in_shape, weights_shape, out_shape, pad_stride_info); - _reference = compute_reference(in_shape, weights_shape, out_shape, pad_stride_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, PadStrideInfo &pad_stride_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType weights = create_tensor(weights_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Convolution configure function - CLDepthwiseConvolution depthwise_convolution; - depthwise_convolution.configure(&src, &dst, &weights, pad_stride_info); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - - // Compute function - depthwise_convolution.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &weights_shape, const TensorShape &out_shape, const PadStrideInfo &pad_stride_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor weights(weights_shape, DataType::F32); - - fill(src, 0); - fill(weights, 1); - - return reference::depthwise_convolution(src, weights, out_shape, pad_stride_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h deleted file mode 100644 index c2578a9ce0..0000000000 --- a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h +++ /dev/null @@ -1,139 +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. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseSeparableConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape output_shape, - PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info) - { - _target = compute_target(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - _reference = compute_reference(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, - const TensorShape &output_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType depthwise_weights = create_tensor(depthwise_weights_shape, DataType::F32); - TensorType depthwise_out = create_tensor(depthwise_out_shape, DataType::F32); - TensorType pointwise_weights = create_tensor(pointwise_weights_shape, DataType::F32); - TensorType biases = create_tensor(biases_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Separable Convolution Layer configure function - CLDepthwiseSeparableConvolutionLayer depthwise_separable_convolution_layer; - depthwise_separable_convolution_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); - - // Allocate tensors - src.allocator()->allocate(); - depthwise_weights.allocator()->allocate(); - depthwise_out.allocator()->allocate(); - pointwise_weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_out.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!pointwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!biases.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(depthwise_weights), 1); - fill(AccessorType(pointwise_weights), 2); - fill(AccessorType(biases), 3); - - // Compute function - depthwise_separable_convolution_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, const TensorShape &dst_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor depthwise_weights(depthwise_weights_shape, DataType::F32); - SimpleTensor pointwise_weights(pointwise_weights_shape, DataType::F32); - SimpleTensor biases(biases_shape, DataType::F32); - - fill(src, 0); - fill(depthwise_weights, 1); - fill(pointwise_weights, 2); - fill(biases, 3); - - return reference::depthwise_separable_convolution_layer(src, depthwise_weights, depthwise_out_shape, pointwise_weights, biases, dst_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DequantizationLayerFixture.h b/tests/validation_new/fixtures/DequantizationLayerFixture.h deleted file mode 100644 index 35c536d6a0..0000000000 --- a/tests/validation_new/fixtures/DequantizationLayerFixture.h +++ /dev/null @@ -1,147 +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. - */ -#ifndef ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DequantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DequantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Initialize random min and max values - rand_min_max(&_min, &_max); - - _target = compute_target(shape, data_type, _min, _max); - _reference = compute_reference(shape, data_type, _min, _max); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::F32); - - // Create and configure function - FunctionType dequantization_layer; - dequantization_layer.configure(&src, &dst, &min, &max); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - dequantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::dequantization_layer(src, min, max); - } - - /** Generate random constant values to be used as min and max for dequantization. - */ - void rand_min_max(float *min, float *max) - { - std::mt19937 gen(library->seed()); - std::uniform_real_distribution distribution(-10000.0, 10000.0); - - const float n1 = distribution(gen); - const float n2 = distribution(gen); - - if(n1 < n2) - { - *min = n1; - *max = n2; - } - else - { - *min = n2; - *max = n1; - } - } - - TensorType _target{}; - SimpleTensor _reference{}; - float _min = 0.f; - float _max = 0.f; -}; - -template -class DequantizationValidationFixture : public DequantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - DequantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h b/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h deleted file mode 100644 index 0d138b47d9..0000000000 --- a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h +++ /dev/null @@ -1,86 +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 "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DirectConvolutionValidationFixedPointFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type, int fractional_bits) - { - const TensorShape weights_shape(kernel_size, kernel_size, input_shape.z(), num_kernels); - const TensorShape bias_shape(num_kernels); - const PadStrideInfo info(stride_x, stride_y, pad_x, pad_y, DimensionRoundingType::FLOOR); - const TensorShape output_shape = get_output_shape(input_shape, weights_shape, info); - - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -private: - TensorShape get_output_shape(TensorShape in_shape, TensorShape kernel_shape, const PadStrideInfo &info) - { - TensorShape out_shape(in_shape); - const std::pair scaled_dims = scaled_dimensions(in_shape.x(), - in_shape.y(), - kernel_shape.x(), - kernel_shape.y(), - info); - out_shape.set(0, scaled_dims.first); - out_shape.set(1, scaled_dims.second); - out_shape.set(2, kernel_shape[3]); - return out_shape; - } -}; - -template -class DirectConvolutionValidationFixture : public DirectConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type) - { - DirectConvolutionValidationFixedPointFixture::setup(input_shape, stride_x, stride_y, pad_x, pad_y, kernel_size, num_kernels, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/fixtures/FloorFixture.h b/tests/validation_new/fixtures/FloorFixture.h deleted file mode 100644 index ab4c5c7e1e..0000000000 --- a/tests/validation_new/fixtures/FloorFixture.h +++ /dev/null @@ -1,107 +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. - */ -#ifndef ARM_COMPUTE_TEST_FLOOR_FIXTURE -#define ARM_COMPUTE_TEST_FLOOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Floor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class FloorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType floor_func; - floor_func.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - floor_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::floor_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FLOOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h b/tests/validation_new/fixtures/FullyConnectedLayerFixture.h deleted file mode 100644 index 0953b0b67e..0000000000 --- a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h +++ /dev/null @@ -1,250 +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. - */ -#ifndef ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/RawTensor.h" -#include "tests/validation_new/CPP/FullyConnectedLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -RawTensor transpose(const RawTensor &src, int interleave = 1) -{ - // Create reference - TensorShape dst_shape(src.shape()); - dst_shape.set(0, src.shape().y() * interleave); - dst_shape.set(1, std::ceil(src.shape().x() / static_cast(interleave))); - - RawTensor dst{ dst_shape, src.data_type() }; - - // Compute reference - uint8_t *out_ptr = dst.data(); - - for(int i = 0; i < dst.num_elements(); i += interleave) - { - Coordinates coord = index2coord(dst.shape(), i); - size_t coord_x = coord.x(); - coord.set(0, coord.y() * interleave); - coord.set(1, coord_x / interleave); - - const int num_elements = std::min(interleave, src.shape().x() - coord.x()); - - std::copy_n(static_cast(src(coord)), num_elements * src.element_size(), out_ptr); - - out_ptr += interleave * dst.element_size(); - } - - return dst; -} -} // namespace - -template -class FullyConnectedLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type, int fractional_bits) - { - ARM_COMPUTE_UNUSED(weights_shape); - ARM_COMPUTE_UNUSED(bias_shape); - - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - if(is_data_type_float(_data_type)) - { - std::uniform_real_distribution<> distribution(0.5f, 1.f); - library->fill(tensor, distribution, i); - } - else - { - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position) - { - TensorShape reshaped_weights_shape(weights_shape); - - // Test actions depending on the target settings - // - // | reshape | !reshape - // -----------+-----------+--------------------------- - // transpose | | *** - // -----------+-----------+--------------------------- - // !transpose | transpose | transpose & - // | | transpose1xW (if required) - // - // ***: That combination is invalid. But we can ignore the transpose flag and handle all !reshape the same - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y()); - reshaped_weights_shape.set(1, shape_x); - - // Weights have to be passed reshaped - // Transpose 1xW for batched version - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - const int transpose_width = 16 / data_size_from_type(data_type); - const float shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y() * transpose_width); - reshaped_weights_shape.set(1, static_cast(std::ceil(shape_x / transpose_width))); - } - } - - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(reshaped_weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function. - FunctionType fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(bias), 2); - - if(!reshape_weights || !transpose_weights) - { - TensorShape tmp_shape(weights_shape); - RawTensor tmp(tmp_shape, data_type, 1, fixed_point_position); - - // Fill with original shape - fill(tmp, 1); - - // Transpose elementwise - tmp = transpose(tmp); - - // Reshape weights for batched runs - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - // Transpose with interleave - const int interleave_size = 16 / tmp.element_size(); - tmp = transpose(tmp, interleave_size); - } - - AccessorType weights_accessor(weights); - - for(int i = 0; i < tmp.num_elements(); ++i) - { - Coordinates coord = index2coord(tmp.shape(), i); - std::copy_n(static_cast(tmp(coord)), - tmp.element_size(), - static_cast(weights_accessor(coord))); - } - } - else - { - fill(AccessorType(weights), 1); - } - - // Compute NEFullyConnectedLayer function - fc.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::fully_connected_layer(src, weights, bias, output_shape); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class FullyConnectedLayerValidationFixture : public FullyConnectedLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type) - { - FullyConnectedLayerValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, - reshape_weights, data_type, - 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/GEMMFixture.h b/tests/validation_new/fixtures/GEMMFixture.h deleted file mode 100644 index a6ab518d74..0000000000 --- a/tests/validation_new/fixtures/GEMMFixture.h +++ /dev/null @@ -1,152 +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. - */ -#ifndef ARM_COMPUTE_TEST_GEMM_FIXTURE -#define ARM_COMPUTE_TEST_GEMM_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/GEMM.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class GEMMValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - _reference = compute_reference(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType a = create_tensor(shape_a, data_type, 1, fixed_point_position); - TensorType b = create_tensor(shape_b, data_type, 1, fixed_point_position); - TensorType c = create_tensor(shape_c, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(a), 0); - fill(AccessorType(b), 1); - fill(AccessorType(c), 2); - - // Compute GEMM function - gemm.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor a{ shape_a, data_type, 1, fixed_point_position }; - SimpleTensor b{ shape_b, data_type, 1, fixed_point_position }; - SimpleTensor c{ shape_c, data_type, 1, fixed_point_position }; - - // Fill reference - fill(a, 0); - fill(b, 1); - fill(c, 2); - - return reference::gemm(a, b, c, alpha, beta); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class GEMMValidationFixture : public GEMMValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type) - { - GEMMValidationFixedPointFixture::setup(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GEMM_FIXTURE */ diff --git a/tests/validation_new/fixtures/L2NormalizeFixture.h b/tests/validation_new/fixtures/L2NormalizeFixture.h deleted file mode 100644 index 5102b93f51..0000000000 --- a/tests/validation_new/fixtures/L2NormalizeFixture.h +++ /dev/null @@ -1,107 +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. - */ -#ifndef ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE -#define ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/L2Normalize.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class L2NormalizeValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, float epsilon) - { - _target = compute_target(shape, data_type, axis, epsilon); - _reference = compute_reference(shape, data_type, axis, epsilon); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType l2_norm_func; - l2_norm_func.configure(&src, &dst, axis, epsilon); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - l2_norm_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::l2_normalize(src, axis, epsilon); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE */ diff --git a/tests/validation_new/fixtures/MeanStdDevFixture.h b/tests/validation_new/fixtures/MeanStdDevFixture.h deleted file mode 100644 index 65622fca07..0000000000 --- a/tests/validation_new/fixtures/MeanStdDevFixture.h +++ /dev/null @@ -1,102 +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. - */ -#ifndef ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE -#define ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE - -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/validation_new/CPP/MeanStdDev.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class MeanStdDevValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - std::pair compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.0f; - float std_dev = 0.0f; - - // Create and configure function - FunctionType mean_std_dev; - mean_std_dev.configure(&src, &mean, &std_dev); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - mean_std_dev.run(); - - return std::make_pair(mean, std_dev); - } - - std::pair compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - // Compute reference - return reference::mean_and_standard_deviation(src); - } - - std::pair _target{}; - std::pair _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE */ diff --git a/tests/validation_new/fixtures/NormalizationLayerFixture.h b/tests/validation_new/fixtures/NormalizationLayerFixture.h deleted file mode 100644 index 044405473b..0000000000 --- a/tests/validation_new/fixtures/NormalizationLayerFixture.h +++ /dev/null @@ -1,133 +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. - */ -#ifndef ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/NormalizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class NormalizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - NormalizationLayerInfo info(norm_type, norm_size, 5, beta); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - library->fill_tensor_uniform(tensor, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType norm_layer; - norm_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - norm_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::normalization_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class NormalizationValidationFixture : public NormalizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type) - { - NormalizationValidationFixedPointFixture::setup(shape, norm_type, norm_size, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/PoolingLayerFixture.h b/tests/validation_new/fixtures/PoolingLayerFixture.h deleted file mode 100644 index c0c818f3a0..0000000000 --- a/tests/validation_new/fixtures/PoolingLayerFixture.h +++ /dev/null @@ -1,134 +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. - */ -#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/PoolingLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class PoolingLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - PoolingLayerInfo info(pool_type, pool_size, pad_stride_info); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1.f, 1.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst; - - // Create and configure function - FunctionType pool_layer; - pool_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - pool_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::pooling_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class PoolingLayerValidationFixture : public PoolingLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type) - { - PoolingLayerValidationFixedPointFixture::setup(shape, pool_type, pool_size, pad_stride_info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/QuantizationLayerFixture.h b/tests/validation_new/fixtures/QuantizationLayerFixture.h deleted file mode 100644 index 469fd5f231..0000000000 --- a/tests/validation_new/fixtures/QuantizationLayerFixture.h +++ /dev/null @@ -1,120 +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. - */ -#ifndef ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/QuantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class QuantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::U8); - - // Create and configure function - FunctionType quantization_layer; - quantization_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - quantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::quantization_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class QuantizationValidationFixture : public QuantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - QuantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/ReductionOperationFixture.h b/tests/validation_new/fixtures/ReductionOperationFixture.h deleted file mode 100644 index 416aadf8d7..0000000000 --- a/tests/validation_new/fixtures/ReductionOperationFixture.h +++ /dev/null @@ -1,116 +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. - */ -#ifndef ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE -#define ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ReductionOperation.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ReductionOperationValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - const TensorShape output_shape = get_output_shape(shape, axis); - _target = compute_target(shape, output_shape, data_type, axis, op); - _reference = compute_reference(shape, output_shape, data_type, axis, op); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create tensors - TensorType src = create_tensor(src_shape, data_type); - TensorType dst = create_tensor(dst_shape, data_type); - - // Create and configure function - FunctionType reduction_func; - reduction_func.configure(&src, &dst, axis, op); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - reduction_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create reference - SimpleTensor src{ src_shape, data_type }; - - // Fill reference - fill(src); - - return reference::reduction_operation(src, dst_shape, axis, op); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - TensorShape get_output_shape(TensorShape shape, unsigned int axis) - { - TensorShape output_shape(shape); - output_shape.set(axis, 1); - return output_shape; - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE */ diff --git a/tests/validation_new/fixtures/ScaleFixture.h b/tests/validation_new/fixtures/ScaleFixture.h deleted file mode 100644 index 74dc0d6816..0000000000 --- a/tests/validation_new/fixtures/ScaleFixture.h +++ /dev/null @@ -1,127 +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. - */ -#ifndef ARM_COMPUTE_TEST_SCALE_FIXTURE -#define ARM_COMPUTE_TEST_SCALE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Scale.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ScaleValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, InterpolationPolicy policy, BorderMode border_mode) - { - _shape = shape; - _policy = policy; - _border_mode = border_mode; - _data_type = data_type; - - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 4); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - std::uniform_int_distribution distribution_u8(0, 255); - uint8_t constant_border_value = distribution_u8(generator); - - _target = compute_target(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - _reference = compute_reference(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create tensors - TensorType src = create_tensor(shape, _data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - TensorType dst = create_tensor(shape_scaled, _data_type); - - // Create and configure function - FunctionType scale; - - scale.configure(&src, &dst, policy, border_mode, constant_border_value); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - scale.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create reference - SimpleTensor src{ shape, _data_type }; - - // Fill reference - fill(src); - - return reference::scale(src, scale_x, scale_y, policy, border_mode, constant_border_value); - } - - TensorType _target{}; - SimpleTensor _reference{}; - TensorShape _shape{}; - InterpolationPolicy _policy{}; - BorderMode _border_mode{}; - DataType _data_type{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SCALE_FIXTURE */ \ No newline at end of file diff --git a/tests/validation_new/fixtures/SoftmaxLayerFixture.h b/tests/validation_new/fixtures/SoftmaxLayerFixture.h deleted file mode 100644 index c6f3d2216f..0000000000 --- a/tests/validation_new/fixtures/SoftmaxLayerFixture.h +++ /dev/null @@ -1,133 +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. - */ -#ifndef ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/SoftmaxLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class SoftmaxValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - - _target = compute_target(shape, data_type, fractional_bits); - _reference = compute_reference(shape, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1000.f, 1000.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType smx_layer; - smx_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - smx_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::softmax_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class SoftmaxValidationFixture : public SoftmaxValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - SoftmaxValidationFixedPointFixture::setup(shape, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE */ diff --git a/tests/validation_new/half.h b/tests/validation_new/half.h deleted file mode 100644 index 0ca620cf57..0000000000 --- a/tests/validation_new/half.h +++ /dev/null @@ -1,38 +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. - */ -#ifndef __ARM_COMPUTE_TEST_HALF_H__ -#define __ARM_COMPUTE_TEST_HALF_H__ - -#ifdef __ANDROID__ -// Android toolchain is broken and doesn't support all CPP11 math functions. -#define HALF_ENABLE_CPP11_CMATH 0 -#endif /* __ANDROID__ */ - -// Set style to round to nearest -#define HALF_ROUND_STYLE 1 -#define HALF_ROUND_TIES_TO_EVEN 1 - -#include "half/half.hpp" - -#endif /* __ARM_COMPUTE_TEST_HALF_H__ */ -- cgit v1.2.1