From 432a7d4845598bf681d968e5ee4ed18fce8496c4 Mon Sep 17 00:00:00 2001 From: Ioan-Cristian Szabo Date: Thu, 12 Oct 2017 09:25:19 +0100 Subject: Porting accumulate tests to the new framework. (COMPMID-626) accumulate_validation (COMPMID-573) accumulate_weighted_validation (COMPMID-574) accumulate_squared_validation Change-Id: I6a0db46e809e03d785515ca51e867bec9c29e376 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/91758 Reviewed-by: Georgios Pinitas Reviewed-by: Pablo Tello Tested-by: Kaizen --- tests/SConscript | 4 - tests/validation/CL/Accumulate.cpp | 189 ++++ tests/validation/CPP/Accumulate.cpp | 103 +++ tests/validation/CPP/Accumulate.h | 50 ++ tests/validation/NEON/Accumulate.cpp | 189 ++++ tests/validation/fixtures/AccumulateFixture.h | 193 ++++ tests/validation_old/AssetsLibrary.cpp | 446 ---------- tests/validation_old/AssetsLibrary.h | 674 -------------- tests/validation_old/CL/CLFixture.cpp | 32 - tests/validation_old/CL/CLFixture.h | 45 - tests/validation_old/CL/ROIPoolingLayer.cpp | 112 --- tests/validation_old/Datasets.h | 264 ------ tests/validation_old/FixedPoint.h | 986 --------------------- tests/validation_old/Helpers.h | 273 ------ tests/validation_old/NEON/AbsoluteDifference.cpp | 200 ----- tests/validation_old/NEON/Accumulate.cpp | 145 --- tests/validation_old/NEON/AccumulateSquared.cpp | 146 --- tests/validation_old/NEON/AccumulateWeighted.cpp | 145 --- tests/validation_old/NEON/ROIPoolingLayer.cpp | 110 --- tests/validation_old/ProgramOptions.cpp | 87 -- tests/validation_old/ProgramOptions.h | 101 --- tests/validation_old/RawTensor.cpp | 67 -- tests/validation_old/RawTensor.h | 86 -- tests/validation_old/Reference.cpp | 156 ---- tests/validation_old/Reference.h | 108 --- tests/validation_old/ReferenceCPP.cpp | 152 ---- tests/validation_old/ReferenceCPP.h | 139 --- tests/validation_old/SConscript | 120 --- tests/validation_old/Tensor.h | 118 --- tests/validation_old/TensorFactory.h | 111 --- tests/validation_old/TensorOperations.h | 687 -------------- tests/validation_old/TensorVisitors.h | 130 --- tests/validation_old/UserConfiguration.cpp | 55 -- tests/validation_old/UserConfiguration.h | 136 --- tests/validation_old/Validation.cpp | 477 ---------- tests/validation_old/Validation.h | 152 ---- tests/validation_old/ValidationProgramOptions.cpp | 50 -- tests/validation_old/ValidationProgramOptions.h | 45 - tests/validation_old/ValidationUserConfiguration.h | 42 - tests/validation_old/boost_wrapper.h | 40 - .../dataset/ActivationFunctionDataset.h | 67 -- .../dataset/ActivationLayerDataset.h | 177 ---- .../dataset/BatchNormalizationLayerDataset.h | 90 -- tests/validation_old/dataset/BorderModeDataset.h | 82 -- .../validation_old/dataset/ConvertPolicyDataset.h | 82 -- .../dataset/ConvolutionLayerDataset.h | 273 ------ tests/validation_old/dataset/DataTypeDatasets.h | 193 ---- .../dataset/FullyConnectedLayerDataset.h | 155 ---- tests/validation_old/dataset/GEMMDataset.h | 220 ----- tests/validation_old/dataset/GenericDataset.h | 97 -- tests/validation_old/dataset/ImageDatasets.h | 120 --- .../dataset/InterpolationPolicyDataset.h | 80 -- .../validation_old/dataset/MatrixPatternDataset.h | 82 -- .../dataset/NonLinearFilterFunctionDataset.h | 82 -- .../dataset/NormalizationLayerDataset.h | 99 --- .../dataset/NormalizationTypeDataset.h | 80 -- tests/validation_old/dataset/PoolingLayerDataset.h | 138 --- tests/validation_old/dataset/PoolingTypesDataset.h | 55 -- .../validation_old/dataset/RoundingPolicyDataset.h | 82 -- tests/validation_old/dataset/ShapeDatasets.h | 152 ---- tests/validation_old/dataset/ThresholdDataset.h | 95 -- tests/validation_old/half.h | 37 - tests/validation_old/main.cpp | 97 -- 63 files changed, 724 insertions(+), 9276 deletions(-) create mode 100644 tests/validation/CL/Accumulate.cpp create mode 100644 tests/validation/CPP/Accumulate.cpp create mode 100644 tests/validation/CPP/Accumulate.h create mode 100644 tests/validation/NEON/Accumulate.cpp create mode 100644 tests/validation/fixtures/AccumulateFixture.h delete mode 100644 tests/validation_old/AssetsLibrary.cpp delete mode 100644 tests/validation_old/AssetsLibrary.h delete mode 100644 tests/validation_old/CL/CLFixture.cpp delete mode 100644 tests/validation_old/CL/CLFixture.h delete mode 100644 tests/validation_old/CL/ROIPoolingLayer.cpp delete mode 100644 tests/validation_old/Datasets.h delete mode 100644 tests/validation_old/FixedPoint.h delete mode 100644 tests/validation_old/Helpers.h delete mode 100644 tests/validation_old/NEON/AbsoluteDifference.cpp delete mode 100644 tests/validation_old/NEON/Accumulate.cpp delete mode 100644 tests/validation_old/NEON/AccumulateSquared.cpp delete mode 100644 tests/validation_old/NEON/AccumulateWeighted.cpp delete mode 100644 tests/validation_old/NEON/ROIPoolingLayer.cpp delete mode 100644 tests/validation_old/ProgramOptions.cpp delete mode 100644 tests/validation_old/ProgramOptions.h delete mode 100644 tests/validation_old/RawTensor.cpp delete mode 100644 tests/validation_old/RawTensor.h delete mode 100644 tests/validation_old/Reference.cpp delete mode 100644 tests/validation_old/Reference.h delete mode 100644 tests/validation_old/ReferenceCPP.cpp delete mode 100644 tests/validation_old/ReferenceCPP.h delete mode 100644 tests/validation_old/SConscript delete mode 100644 tests/validation_old/Tensor.h delete mode 100644 tests/validation_old/TensorFactory.h delete mode 100644 tests/validation_old/TensorOperations.h delete mode 100644 tests/validation_old/TensorVisitors.h delete mode 100644 tests/validation_old/UserConfiguration.cpp delete mode 100644 tests/validation_old/UserConfiguration.h delete mode 100644 tests/validation_old/Validation.cpp delete mode 100644 tests/validation_old/Validation.h delete mode 100644 tests/validation_old/ValidationProgramOptions.cpp delete mode 100644 tests/validation_old/ValidationProgramOptions.h delete mode 100644 tests/validation_old/ValidationUserConfiguration.h delete mode 100644 tests/validation_old/boost_wrapper.h delete mode 100644 tests/validation_old/dataset/ActivationFunctionDataset.h delete mode 100644 tests/validation_old/dataset/ActivationLayerDataset.h delete mode 100644 tests/validation_old/dataset/BatchNormalizationLayerDataset.h delete mode 100644 tests/validation_old/dataset/BorderModeDataset.h delete mode 100644 tests/validation_old/dataset/ConvertPolicyDataset.h delete mode 100644 tests/validation_old/dataset/ConvolutionLayerDataset.h delete mode 100644 tests/validation_old/dataset/DataTypeDatasets.h delete mode 100644 tests/validation_old/dataset/FullyConnectedLayerDataset.h delete mode 100644 tests/validation_old/dataset/GEMMDataset.h delete mode 100644 tests/validation_old/dataset/GenericDataset.h delete mode 100644 tests/validation_old/dataset/ImageDatasets.h delete mode 100644 tests/validation_old/dataset/InterpolationPolicyDataset.h delete mode 100644 tests/validation_old/dataset/MatrixPatternDataset.h delete mode 100644 tests/validation_old/dataset/NonLinearFilterFunctionDataset.h delete mode 100644 tests/validation_old/dataset/NormalizationLayerDataset.h delete mode 100644 tests/validation_old/dataset/NormalizationTypeDataset.h delete mode 100644 tests/validation_old/dataset/PoolingLayerDataset.h delete mode 100644 tests/validation_old/dataset/PoolingTypesDataset.h delete mode 100644 tests/validation_old/dataset/RoundingPolicyDataset.h delete mode 100644 tests/validation_old/dataset/ShapeDatasets.h delete mode 100644 tests/validation_old/dataset/ThresholdDataset.h delete mode 100644 tests/validation_old/half.h delete mode 100644 tests/validation_old/main.cpp (limited to 'tests') diff --git a/tests/SConscript b/tests/SConscript index 007a0aa66a..9c9897ea0e 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -27,10 +27,6 @@ Import('vars') SConscript('./framework/SConscript', duplicate=0) -#FIXME: Remove before release -if env['internal_only']: - SConscript('./validation_old/SConscript', duplicate=0) - # vars is imported from arm_compute: variables = [ BoolVariable("validation_tests", "Build validation test programs", True), diff --git a/tests/validation/CL/Accumulate.cpp b/tests/validation/CL/Accumulate.cpp new file mode 100644 index 0000000000..2e33540b5d --- /dev/null +++ b/tests/validation/CL/Accumulate.cpp @@ -0,0 +1,189 @@ +/* + * 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/CLAccumulate.h" +#include "tests/CL/CLAccessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ConvertPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/AccumulateFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr AbsoluteTolerance tolerance(1.0f); +/** Input data sets **/ +const auto AccumulateU8Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)); +const auto AccumulateS16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S16)); +} // namespace +TEST_SUITE(CL) +TEST_SUITE(Accumulate) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateS16Dataset), + shape, data_type, output_data_type) +{ + // Create tensors + CLTensor ref_src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + CLAccumulate accum; + accum.configure(&ref_src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLAccumulateFixture = AccumulateValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLAccumulateFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLAccumulateFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(AccumulateWeighted) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateU8Dataset), + shape, data_type, output_data_type) +{ + // Generate a random alpha value + std::mt19937 gen(library->seed()); + std::uniform_real_distribution<> float_dist(0, 1); + const float alpha = float_dist(gen); + + // Create tensors + CLTensor ref_src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + CLAccumulateWeighted accum_weight; + accum_weight.configure(&ref_src, alpha, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLAccumulateWeightedFixture = AccumulateWeightedValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLAccumulateWeightedFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateU8Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLAccumulateWeightedFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateU8Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(AccumulateSquared) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateS16Dataset), + shape, data_type, output_data_type) +{ + // Generate a random shift value + std::mt19937 gen(library->seed()); + std::uniform_int_distribution int_dist(0, 15); + const uint32_t shift = int_dist(gen); + + // Create tensors + CLTensor ref_src = create_tensor(shape, data_type); + CLTensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + CLAccumulateSquared accum_square; + accum_square.configure(&ref_src, shift, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using CLAccumulateSquaredFixture = AccumulateSquaredValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, CLAccumulateSquaredFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, CLAccumulateSquaredFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(CLAccessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Accumulate.cpp b/tests/validation/CPP/Accumulate.cpp new file mode 100644 index 0000000000..29a2007bbd --- /dev/null +++ b/tests/validation/CPP/Accumulate.cpp @@ -0,0 +1,103 @@ +/* + * 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 "Accumulate.h" + +#include "arm_compute/core/Types.h" +#include "tests/validation/FixedPoint.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor accumulate(const SimpleTensor &src, DataType output_data_type) +{ + SimpleTensor dst{ src.shape(), output_data_type }; + + library->fill_tensor_uniform(dst, 1, static_cast(0), static_cast(std::numeric_limits::max())); + + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < src.num_elements(); ++i) + { + intermediate_type val = static_cast(src[i]) + static_cast(dst[i]); + dst[i] = saturate_cast(val); + } + + return dst; +} + +template +SimpleTensor accumulate_weighted(const SimpleTensor &src, float alpha, DataType output_data_type) +{ + ARM_COMPUTE_ERROR_ON_MSG(alpha < 0.f || alpha > 1.f, "Weight (alpha) specified in accumulate_weighted must be within the range [0, 1]"); + + SimpleTensor dst{ src.shape(), output_data_type }; + + library->fill_tensor_uniform(dst, 1, static_cast(0), static_cast(std::numeric_limits::max())); + + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + + for(int i = 0; i < src.num_elements(); ++i) + { + double val = (1. - static_cast(alpha)) * static_cast(dst[i]) + static_cast(alpha) * static_cast(src[i]); + dst[i] = static_cast(val); + } + + return dst; +} + +template +SimpleTensor accumulate_squared(const SimpleTensor &src, uint32_t shift, DataType output_data_type) +{ + ARM_COMPUTE_ERROR_ON_MSG(shift > 15, "Shift in accumulate_squared must be within the range [0, 15]"); + + SimpleTensor dst{ src.shape(), output_data_type }; + + library->fill_tensor_uniform(dst, 1, static_cast(0), static_cast(std::numeric_limits::max())); + + using intermediate_type = typename common_promoted_signed_type::intermediate_type; + intermediate_type denom = 1 << shift; + + for(int i = 0; i < src.num_elements(); ++i) + { + intermediate_type val = static_cast(dst[i]) + (static_cast(src[i]) * static_cast(src[i]) / denom); + dst[i] = saturate_cast(val); + } + + return dst; +} + +template SimpleTensor accumulate(const SimpleTensor &src, DataType output_data_type); +template SimpleTensor accumulate_weighted(const SimpleTensor &src, float alpha, DataType output_data_type); +template SimpleTensor accumulate_squared(const SimpleTensor &src, uint32_t shift, DataType output_data_type); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/CPP/Accumulate.h b/tests/validation/CPP/Accumulate.h new file mode 100644 index 0000000000..faa570bd05 --- /dev/null +++ b/tests/validation/CPP/Accumulate.h @@ -0,0 +1,50 @@ +/* + * 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_ACCUMULATE_H__ +#define __ARM_COMPUTE_TEST_ACCUMULATE_H__ + +#include "tests/SimpleTensor.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace reference +{ +template +SimpleTensor accumulate(const SimpleTensor &src, DataType output_data_type); + +template +SimpleTensor accumulate_weighted(const SimpleTensor &src, float alpha, DataType output_data_type); + +template +SimpleTensor accumulate_squared(const SimpleTensor &src, uint32_t shift, DataType output_data_type); +} // namespace reference +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* __ARM_COMPUTE_TEST_ACCUMULATE_H__ */ diff --git a/tests/validation/NEON/Accumulate.cpp b/tests/validation/NEON/Accumulate.cpp new file mode 100644 index 0000000000..cb6894a586 --- /dev/null +++ b/tests/validation/NEON/Accumulate.cpp @@ -0,0 +1,189 @@ +/* + * 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/NEAccumulate.h" +#include "arm_compute/runtime/Tensor.h" +#include "arm_compute/runtime/TensorAllocator.h" +#include "tests/NEON/Accessor.h" +#include "tests/PaddingCalculator.h" +#include "tests/datasets/ConvertPolicyDataset.h" +#include "tests/datasets/ShapeDatasets.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/Validation.h" +#include "tests/validation/fixtures/AccumulateFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +/** Tolerance value for comparing reference's output against implementation's output for floating point data types */ +constexpr AbsoluteTolerance tolerance(1.0f); +/** Input data sets **/ +const auto AccumulateU8Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U8)); +const auto AccumulateS16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S16)); +} // namespace +TEST_SUITE(NEON) +TEST_SUITE(Accumulate) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateS16Dataset), + shape, data_type, output_data_type) +{ + // Create tensors + Tensor ref_src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + NEAccumulate accum; + accum.configure(&ref_src, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEAccumulateFixture = AccumulateValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEAccumulateFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEAccumulateFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(AccumulateWeighted) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateU8Dataset), + shape, data_type, output_data_type) +{ + // Generate a random alpha value + std::mt19937 gen(library->seed()); + std::uniform_real_distribution<> float_dist(0, 1); + const float alpha = float_dist(gen); + + // Create tensors + Tensor ref_src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + NEAccumulateWeighted accum_weight; + accum_weight.configure(&ref_src, alpha, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEAccumulateWeightedFixture = AccumulateWeightedValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEAccumulateWeightedFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateU8Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEAccumulateWeightedFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateU8Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE(AccumulateSquared) + +TEST_SUITE(U8) +DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallShapes(), datasets::LargeShapes()), AccumulateS16Dataset), + shape, data_type, output_data_type) +{ + // Generate a random shift value + std::mt19937 gen(library->seed()); + std::uniform_int_distribution int_dist(0, 15); + const uint32_t shift = int_dist(gen); + + // Create tensors + Tensor ref_src = create_tensor(shape, data_type); + Tensor dst = create_tensor(shape, output_data_type); + + // Create and Configure function + NEAccumulateSquared accum_square; + accum_square.configure(&ref_src, shift, &dst); + + // Validate valid region + const ValidRegion valid_region = shape_to_valid_region(shape); + validate(dst.info()->valid_region(), valid_region); + + // Validate padding + const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); + validate(ref_src.info()->padding(), padding); + validate(dst.info()->padding(), padding); +} + +template +using NEAccumulateSquaredFixture = AccumulateSquaredValidationFixture; + +FIXTURE_DATA_TEST_CASE(RunSmall, NEAccumulateSquaredFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} +FIXTURE_DATA_TEST_CASE(RunLarge, NEAccumulateSquaredFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeShapes(), AccumulateS16Dataset)) +{ + // Validate output + validate(Accessor(_target), _reference, tolerance); +} + +TEST_SUITE_END() +TEST_SUITE_END() + +TEST_SUITE_END() +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/fixtures/AccumulateFixture.h b/tests/validation/fixtures/AccumulateFixture.h new file mode 100644 index 0000000000..3d8ca2dafc --- /dev/null +++ b/tests/validation/fixtures/AccumulateFixture.h @@ -0,0 +1,193 @@ +/* + * 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_ACCUMULATE_FIXTURE +#define ARM_COMPUTE_TEST_ACCUMULATE_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/CPP/Accumulate.h" +#include "tests/validation/Helpers.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +template +class AccumulateBaseValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, DataType output_data_type) + { + _target = compute_target(shape, data_type, output_data_type); + _reference = compute_reference(shape, data_type, output_data_type); + } + +protected: + template + void fill(U &&tensor, int i, D max) + { + library->fill_tensor_uniform(tensor, i, static_cast(0), max); + } + + TensorType compute_target(const TensorShape &shape, DataType data_type, DataType output_data_type) + { + // Create tensors + TensorType ref_src = create_tensor(shape, data_type); + TensorType dst = create_tensor(shape, output_data_type); + + // Create and configure function + FunctionType accum; + accum_conf(accum, ref_src, dst); + + ARM_COMPUTE_EXPECT(ref_src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + // Allocate tensors + ref_src.allocator()->allocate(); + dst.allocator()->allocate(); + + ARM_COMPUTE_EXPECT(!ref_src.info()->is_resizable(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); + + const T1 max = std::numeric_limits::max(); + + // Fill tensors + fill(AccessorType(ref_src), 0, max); + fill(AccessorType(dst), 1, static_cast(max)); + + // Compute function + accum.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, DataType output_data_type) + { + // Create reference + SimpleTensor ref_src{ shape, data_type }; + + const T1 max = std::numeric_limits::max(); + + // Fill reference + fill(ref_src, 0, max); + + return accum_ref(ref_src, output_data_type); + } + + virtual void accum_conf(FunctionType &func, const TensorType &input, TensorType &accum) = 0; + + virtual SimpleTensor accum_ref(const SimpleTensor &input, DataType output_data_type) = 0; + + TensorType _target{}; + SimpleTensor _reference{}; +}; + +template +class AccumulateValidationFixture : public AccumulateBaseValidationFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, DataType output_data_type) + { + AccumulateBaseValidationFixture::setup(shape, data_type, output_data_type); + } + + virtual void accum_conf(FunctionType &func, const TensorType &input, TensorType &accum) override + { + func.configure(&input, &accum); + } + + virtual SimpleTensor accum_ref(const SimpleTensor &input, DataType output_data_type) override + { + return reference::accumulate(input, output_data_type); + } +}; + +template +class AccumulateWeightedValidationFixture : public AccumulateBaseValidationFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, DataType output_data_type) + { + std::mt19937 gen(library->seed()); + std::uniform_real_distribution<> float_dist(0, 1); + + _alpha = float_dist(gen); + + AccumulateBaseValidationFixture::setup(shape, data_type, output_data_type); + } + + virtual void accum_conf(FunctionType &func, const TensorType &input, TensorType &accum) override + { + func.configure(&input, _alpha, &accum); + } + + virtual SimpleTensor accum_ref(const SimpleTensor &input, DataType output_data_type) override + { + return reference::accumulate_weighted(input, _alpha, output_data_type); + } + + float _alpha{ 0.f }; +}; + +template +class AccumulateSquaredValidationFixture : public AccumulateBaseValidationFixture +{ +public: + template + void setup(TensorShape shape, DataType data_type, DataType output_data_type) + { + std::mt19937 gen(library->seed()); + std::uniform_int_distribution int_dist(0, 15); + + _shift = int_dist(gen); + + AccumulateBaseValidationFixture::setup(shape, data_type, output_data_type); + } + + virtual void accum_conf(FunctionType &func, const TensorType &input, TensorType &accum) override + { + func.configure(&input, _shift, &accum); + } + + virtual SimpleTensor accum_ref(const SimpleTensor &input, DataType output_data_type) override + { + return reference::accumulate_squared(input, _shift, output_data_type); + } + + uint32_t _shift{ 0U }; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ACCUMULATE_FIXTURE */ diff --git a/tests/validation_old/AssetsLibrary.cpp b/tests/validation_old/AssetsLibrary.cpp deleted file mode 100644 index 997af27a9f..0000000000 --- a/tests/validation_old/AssetsLibrary.cpp +++ /dev/null @@ -1,446 +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/AssetsLibrary.h" - -#include "arm_compute/core/ITensor.h" -#include "tests/Utils.h" -#include "utils/TypePrinter.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace -{ -template ::value, int>::type = 0> -void rgb_to_luminance(const RawTensor &src, RawTensor &dst) -{ - const size_t min_size = std::min(src.size(), dst.size()); - - for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) - { - reinterpret_cast(dst.data())[j] = 0.2126f * src.data()[i + 0] + 0.7152f * src.data()[i + 1] + 0.0722f * src.data()[i + 2]; - } -} - -void extract_r_from_rgb(const RawTensor &src, RawTensor &dst) -{ - const size_t min_size = std::min(src.size(), dst.size()); - - for(size_t i = 0, j = 0; i < min_size; i += 3, ++j) - { - dst.data()[j] = src.data()[i]; - } -} - -void extract_g_from_rgb(const RawTensor &src, RawTensor &dst) -{ - const size_t min_size = std::min(src.size(), dst.size()); - - for(size_t i = 1, j = 0; i < min_size; i += 3, ++j) - { - dst.data()[j] = src.data()[i]; - } -} - -void discard_comments(std::ifstream &fs) -{ - while(fs.peek() == '#') - { - fs.ignore(std::numeric_limits::max(), '\n'); - } -} - -void discard_comments_and_spaces(std::ifstream &fs) -{ - while(true) - { - discard_comments(fs); - - if(isspace(fs.peek()) == 0) - { - break; - } - - fs.ignore(1); - } -} - -std::tuple parse_ppm_header(std::ifstream &fs) -{ - // Check the PPM magic number is valid - std::array magic_number{ { 0 } }; - fs >> magic_number[0] >> magic_number[1]; - - if(magic_number[0] != 'P' || magic_number[1] != '6') - { - throw std::runtime_error("Only raw PPM format is suported"); - } - - discard_comments_and_spaces(fs); - - unsigned int width = 0; - fs >> width; - - discard_comments_and_spaces(fs); - - unsigned int height = 0; - fs >> height; - - discard_comments_and_spaces(fs); - - int max_value = 0; - fs >> max_value; - - if(!fs.good()) - { - throw std::runtime_error("Cannot read image dimensions"); - } - - if(max_value != 255) - { - throw std::runtime_error("RawTensor doesn't have 8-bit values"); - } - - discard_comments(fs); - - if(isspace(fs.peek()) == 0) - { - throw std::runtime_error("Invalid PPM header"); - } - - fs.ignore(1); - - return std::make_tuple(width, height, max_value); -} - -RawTensor load_ppm(const std::string &path) -{ - std::ifstream file(path, std::ios::in | std::ios::binary); - - if(!file.good()) - { - throw std::runtime_error("Could not load PPM image: " + path); - } - - unsigned int width = 0; - unsigned int height = 0; - - std::tie(width, height, std::ignore) = parse_ppm_header(file); - - RawTensor raw(TensorShape(width, height), Format::RGB888); - - // Check if the file is large enough to fill the image - const size_t current_position = file.tellg(); - file.seekg(0, std::ios_base::end); - const size_t end_position = file.tellg(); - file.seekg(current_position, std::ios_base::beg); - - if((end_position - current_position) < raw.size()) - { - throw std::runtime_error("Not enough data in file"); - } - - file.read(reinterpret_cast(raw.data()), raw.size()); - - if(!file.good()) - { - throw std::runtime_error("Failure while reading image buffer"); - } - - return raw; -} -} // namespace - -AssetsLibrary::AssetsLibrary(std::string path, std::random_device::result_type seed) //NOLINT - : _library_path(std::move(path)), - _seed{ seed } -{ -} - -std::random_device::result_type AssetsLibrary::seed() const -{ - return _seed; -} - -void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Format format) const -{ - //FIXME: Should be done by swapping cached buffers - const RawTensor &src = get(name, format); - std::copy_n(src.data(), raw.size(), raw.data()); -} - -void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Channel channel) const -{ - fill(raw, name, get_format_for_channel(channel), channel); -} - -void AssetsLibrary::fill(RawTensor &raw, const std::string &name, Format format, Channel channel) const -{ - const RawTensor &src = get(name, format, channel); - std::copy_n(src.data(), raw.size(), raw.data()); -} - -const AssetsLibrary::Loader &AssetsLibrary::get_loader(const std::string &extension) const -{ - static std::unordered_map loaders = - { - { "ppm", load_ppm } - }; - - const auto it = loaders.find(extension); - - if(it != loaders.end()) - { - return it->second; - } - else - { - throw std::invalid_argument("Cannot load image with extension '" + extension + "'"); - } -} - -const AssetsLibrary::Converter &AssetsLibrary::get_converter(Format src, Format dst) const -{ - static std::map, Converter> converters = - { - { std::make_pair(Format::RGB888, Format::U8), rgb_to_luminance }, - { std::make_pair(Format::RGB888, Format::U16), rgb_to_luminance }, - { std::make_pair(Format::RGB888, Format::S16), rgb_to_luminance }, - { std::make_pair(Format::RGB888, Format::U32), rgb_to_luminance } - }; - - const auto it = converters.find(std::make_pair(src, dst)); - - if(it != converters.end()) - { - return it->second; - } - else - { - std::stringstream msg; - msg << "Cannot convert from format '" << src << "' to format '" << dst << "'\n"; - throw std::invalid_argument(msg.str()); - } -} - -const AssetsLibrary::Converter &AssetsLibrary::get_converter(DataType src, Format dst) const -{ - static std::map, Converter> converters = {}; - - const auto it = converters.find(std::make_pair(src, dst)); - - if(it != converters.end()) - { - return it->second; - } - else - { - std::stringstream msg; - msg << "Cannot convert from data type '" << src << "' to format '" << dst << "'\n"; - throw std::invalid_argument(msg.str()); - } -} - -const AssetsLibrary::Converter &AssetsLibrary::get_converter(DataType src, DataType dst) const -{ - static std::map, Converter> converters = {}; - - const auto it = converters.find(std::make_pair(src, dst)); - - if(it != converters.end()) - { - return it->second; - } - else - { - std::stringstream msg; - msg << "Cannot convert from data type '" << src << "' to data type '" << dst << "'\n"; - throw std::invalid_argument(msg.str()); - } -} - -const AssetsLibrary::Converter &AssetsLibrary::get_converter(Format src, DataType dst) const -{ - static std::map, Converter> converters = {}; - - const auto it = converters.find(std::make_pair(src, dst)); - - if(it != converters.end()) - { - return it->second; - } - else - { - std::stringstream msg; - msg << "Cannot convert from format '" << src << "' to data type '" << dst << "'\n"; - throw std::invalid_argument(msg.str()); - } -} - -const AssetsLibrary::Extractor &AssetsLibrary::get_extractor(Format format, Channel channel) const -{ - static std::map, Extractor> extractors = - { - { std::make_pair(Format::RGB888, Channel::R), extract_r_from_rgb }, - { std::make_pair(Format::RGB888, Channel::G), extract_g_from_rgb } - }; - - const auto it = extractors.find(std::make_pair(format, channel)); - - if(it != extractors.end()) - { - return it->second; - } - else - { - std::stringstream msg; - msg << "Cannot extract channel '" << channel << "' from format '" << format << "'\n"; - throw std::invalid_argument(msg.str()); - } -} - -RawTensor AssetsLibrary::load_image(const std::string &name) const -{ -#ifdef _WIN32 - const std::string image_path = ("\\images\\"); -#else /* _WIN32 */ - const std::string image_path = ("/images/"); -#endif /* _WIN32 */ - - const std::string path = _library_path + image_path + name; - const std::string extension = path.substr(path.find_last_of('.') + 1); - return (*get_loader(extension))(path); -} - -const RawTensor &AssetsLibrary::find_or_create_raw_tensor(const std::string &name, Format format) const -{ - std::lock_guard guard(_format_lock); - - const RawTensor *ptr = _cache.find(std::make_tuple(name, format)); - - if(ptr != nullptr) - { - return *ptr; - } - - RawTensor raw = load_image(name); - - if(raw.format() != format) - { - //FIXME: Remove unnecessary copy - RawTensor dst(raw.shape(), format); - (*get_converter(raw.format(), format))(raw, dst); - raw = std::move(dst); - } - - return _cache.add(std::make_tuple(name, format), std::move(raw)); -} - -const RawTensor &AssetsLibrary::find_or_create_raw_tensor(const std::string &name, Format format, Channel channel) const -{ - std::lock_guard guard(_channel_lock); - - const RawTensor *ptr = _cache.find(std::make_tuple(name, format, channel)); - - if(ptr != nullptr) - { - return *ptr; - } - - const RawTensor &src = get(name, format); - //FIXME: Need to change shape to match channel - RawTensor dst(src.shape(), get_channel_format(channel)); - - (*get_extractor(format, channel))(src, dst); - - return _cache.add(std::make_tuple(name, format, channel), std::move(dst)); -} - -TensorShape AssetsLibrary::get_image_shape(const std::string &name) -{ - return load_image(name).shape(); -} - -const RawTensor &AssetsLibrary::get(const std::string &name) const -{ - //FIXME: Format should be derived from the image name. Not be fixed to RGB. - return find_or_create_raw_tensor(name, Format::RGB888); -} - -RawTensor AssetsLibrary::get(const std::string &name) -{ - //FIXME: Format should be derived from the image name. Not be fixed to RGB. - return RawTensor(find_or_create_raw_tensor(name, Format::RGB888)); -} - -RawTensor AssetsLibrary::get(const std::string &name, DataType data_type, int num_channels) const -{ - const RawTensor &raw = get(name); - - return RawTensor(raw.shape(), data_type, num_channels); -} - -const RawTensor &AssetsLibrary::get(const std::string &name, Format format) const -{ - return find_or_create_raw_tensor(name, format); -} - -RawTensor AssetsLibrary::get(const std::string &name, Format format) -{ - return RawTensor(find_or_create_raw_tensor(name, format)); -} - -const RawTensor &AssetsLibrary::get(const std::string &name, Channel channel) const -{ - return get(name, get_format_for_channel(channel), channel); -} - -RawTensor AssetsLibrary::get(const std::string &name, Channel channel) -{ - return RawTensor(get(name, get_format_for_channel(channel), channel)); -} - -const RawTensor &AssetsLibrary::get(const std::string &name, Format format, Channel channel) const -{ - return find_or_create_raw_tensor(name, format, channel); -} - -RawTensor AssetsLibrary::get(const std::string &name, Format format, Channel channel) -{ - return RawTensor(find_or_create_raw_tensor(name, format, channel)); -} -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/AssetsLibrary.h b/tests/validation_old/AssetsLibrary.h deleted file mode 100644 index 6945aa6fe1..0000000000 --- a/tests/validation_old/AssetsLibrary.h +++ /dev/null @@ -1,674 +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_TENSOR_LIBRARY_H__ -#define __ARM_COMPUTE_TEST_TENSOR_LIBRARY_H__ - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Window.h" -#include "tests/RawTensor.h" -#include "tests/TensorCache.h" -#include "tests/Utils.h" -#include "tests/validation_old/half.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -/** Factory class to create and fill tensors. - * - * Allows to initialise tensors from loaded images or by specifying the shape - * explicitly. Furthermore, provides methods to fill tensors with the content of - * loaded images or with random values. - */ -class AssetsLibrary final -{ -public: - /** Initialises the library with a @p path to the image directory. - * Furthermore, sets the seed for the random generator to @p seed. - * - * @param[in] path Path to load images from. - * @param[in] seed Seed used to initialise the random number generator. - */ - AssetsLibrary(std::string path, std::random_device::result_type seed); - - /** Seed that is used to fill tensors with random values. */ - std::random_device::result_type seed() const; - - /** Provides a tensor shape for the specified image. - * - * @param[in] name Image file used to look up the raw tensor. - */ - TensorShape get_image_shape(const std::string &name); - - /** Provides a contant raw tensor for the specified image. - * - * @param[in] name Image file used to look up the raw tensor. - */ - const RawTensor &get(const std::string &name) const; - - /** Provides a raw tensor for the specified image. - * - * @param[in] name Image file used to look up the raw tensor. - */ - RawTensor get(const std::string &name); - - /** Creates an uninitialised raw tensor with the given @p data_type and @p - * num_channels. The shape is derived from the specified image. - * - * @param[in] name Image file used to initialise the tensor. - * @param[in] data_type Data type used to initialise the tensor. - * @param[in] num_channels Number of channels used to initialise the tensor. - */ - RawTensor get(const std::string &name, DataType data_type, int num_channels = 1) const; - - /** Provides a contant raw tensor for the specified image after it has been - * converted to @p format. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - */ - const RawTensor &get(const std::string &name, Format format) const; - - /** Provides a raw tensor for the specified image after it has been - * converted to @p format. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - */ - RawTensor get(const std::string &name, Format format); - - /** Provides a contant raw tensor for the specified channel after it has - * been extracted form the given image. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] channel Channel used to look up the raw tensor. - * - * @note The channel has to be unambiguous so that the format can be - * inferred automatically. - */ - const RawTensor &get(const std::string &name, Channel channel) const; - - /** Provides a raw tensor for the specified channel after it has been - * extracted form the given image. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] channel Channel used to look up the raw tensor. - * - * @note The channel has to be unambiguous so that the format can be - * inferred automatically. - */ - RawTensor get(const std::string &name, Channel channel); - - /** Provides a constant raw tensor for the specified channel after it has - * been extracted form the given image formatted to @p format. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - * @param[in] channel Channel used to look up the raw tensor. - */ - const RawTensor &get(const std::string &name, Format format, Channel channel) const; - - /** Provides a raw tensor for the specified channel after it has been - * extracted form the given image formatted to @p format. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - * @param[in] channel Channel used to look up the raw tensor. - */ - RawTensor get(const std::string &name, Format format, Channel channel); - - /** Puts garbage values all around the tensor for testing purposes - * - * @param[in, out] tensor To be filled tensor. - * @param[in] distribution Distribution used to fill the tensor's surroundings. - * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. - */ - template - void fill_borders_with_garbage(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const; - - /** Fills the specified @p tensor with random values drawn from @p - * distribution. - * - * @param[in, out] tensor To be filled tensor. - * @param[in] distribution Distribution used to fill the tensor. - * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. - * - * @note The @p distribution has to provide operator(Generator &) which - * will be used to draw samples. - */ - template - void fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const; - - /** Fills the specified @p raw tensor with random values drawn from @p - * distribution. - * - * @param[in, out] raw To be filled raw. - * @param[in] distribution Distribution used to fill the tensor. - * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. - * - * @note The @p distribution has to provide operator(Generator &) which - * will be used to draw samples. - */ - template - void fill(RawTensor &raw, D &&distribution, std::random_device::result_type seed_offset) const; - - /** Fills the specified @p tensor with the content of the specified image - * converted to the given format. - * - * @param[in, out] tensor To be filled tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] format Format of the image used to fill the tensor. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - template - void fill(T &&tensor, const std::string &name, Format format) const; - - /** Fills the raw tensor with the content of the specified image - * converted to the given format. - * - * @param[in, out] raw To be filled raw tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] format Format of the image used to fill the tensor. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - void fill(RawTensor &raw, const std::string &name, Format format) const; - - /** Fills the specified @p tensor with the content of the specified channel - * extracted from the given image. - * - * @param[in, out] tensor To be filled tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] channel Channel of the image used to fill the tensor. - * - * @note The channel has to be unambiguous so that the format can be - * inferred automatically. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - template - void fill(T &&tensor, const std::string &name, Channel channel) const; - - /** Fills the raw tensor with the content of the specified channel - * extracted from the given image. - * - * @param[in, out] raw To be filled raw tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] channel Channel of the image used to fill the tensor. - * - * @note The channel has to be unambiguous so that the format can be - * inferred automatically. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - void fill(RawTensor &raw, const std::string &name, Channel channel) const; - - /** Fills the specified @p tensor with the content of the specified channel - * extracted from the given image after it has been converted to the given - * format. - * - * @param[in, out] tensor To be filled tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] format Format of the image used to fill the tensor. - * @param[in] channel Channel of the image used to fill the tensor. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - template - void fill(T &&tensor, const std::string &name, Format format, Channel channel) const; - - /** Fills the raw tensor with the content of the specified channel - * extracted from the given image after it has been converted to the given - * format. - * - * @param[in, out] raw To be filled raw tensor. - * @param[in] name Image file used to fill the tensor. - * @param[in] format Format of the image used to fill the tensor. - * @param[in] channel Channel of the image used to fill the tensor. - * - * @warning No check is performed that the specified format actually - * matches the format of the tensor. - */ - void fill(RawTensor &raw, const std::string &name, Format format, Channel channel) const; - - /** Fill a tensor with uniform distribution across the range of its type - * - * @param[in, out] tensor To be filled tensor. - * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. - */ - template - void fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const; - - /** Fill a tensor with uniform distribution across the a specified range - * - * @param[in, out] tensor To be filled tensor. - * @param[in] seed_offset The offset will be added to the global seed before initialising the random generator. - * @param[in] low lowest value in the range (inclusive) - * @param[in] high highest value in the range (inclusive) - * - * @note @p low and @p high must be of the same type as the data type of @p tensor - */ - template - void fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset, D low, D high) const; - - /** Fills the specified @p tensor with data loaded from binary in specified path. - * - * @param[in, out] tensor To be filled tensor. - * @param[in] name Data file. - */ - template - void fill_layer_data(T &&tensor, std::string name) const; - -private: - // Function prototype to convert between image formats. - using Converter = void (*)(const RawTensor &src, RawTensor &dst); - // Function prototype to extract a channel from an image. - using Extractor = void (*)(const RawTensor &src, RawTensor &dst); - // Function prototype to load an image file. - using Loader = RawTensor (*)(const std::string &path); - - const Converter &get_converter(Format src, Format dst) const; - const Converter &get_converter(DataType src, Format dst) const; - const Converter &get_converter(Format src, DataType dst) const; - const Converter &get_converter(DataType src, DataType dst) const; - const Extractor &get_extractor(Format format, Channel) const; - const Loader &get_loader(const std::string &extension) const; - - /** Creates a raw tensor from the specified image. - * - * @param[in] name To be loaded image file. - * - * @note If use_single_image is true @p name is ignored and the user image - * is loaded instead. - */ - RawTensor load_image(const std::string &name) const; - - /** Provides a raw tensor for the specified image and format. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - * - * If the tensor has already been requested before the cached version will - * be returned. Otherwise the tensor will be added to the cache. - * - * @note If use_single_image is true @p name is ignored and the user image - * is loaded instead. - */ - const RawTensor &find_or_create_raw_tensor(const std::string &name, Format format) const; - - /** Provides a raw tensor for the specified image, format and channel. - * - * @param[in] name Image file used to look up the raw tensor. - * @param[in] format Format used to look up the raw tensor. - * @param[in] channel Channel used to look up the raw tensor. - * - * If the tensor has already been requested before the cached version will - * be returned. Otherwise the tensor will be added to the cache. - * - * @note If use_single_image is true @p name is ignored and the user image - * is loaded instead. - */ - const RawTensor &find_or_create_raw_tensor(const std::string &name, Format format, Channel channel) const; - - mutable TensorCache _cache{}; - mutable std::mutex _format_lock{}; - mutable std::mutex _channel_lock{}; - const std::string _library_path; - std::random_device::result_type _seed; -}; - -template -void AssetsLibrary::fill_borders_with_garbage(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const -{ - const PaddingSize padding_size = tensor.padding(); - - Window window; - window.set(0, Window::Dimension(-padding_size.left, tensor.shape()[0] + padding_size.right, 1)); - window.set(1, Window::Dimension(-padding_size.top, tensor.shape()[1] + padding_size.bottom, 1)); - - std::mt19937 gen(_seed); - - execute_window_loop(window, [&](const Coordinates & id) - { - TensorShape shape = tensor.shape(); - - // If outside of valid region - if(id.x() < 0 || id.x() >= static_cast(shape.x()) || id.y() < 0 || id.y() >= static_cast(shape.y())) - { - using ResultType = typename std::remove_reference::type::result_type; - const ResultType value = distribution(gen); - void *const out_ptr = tensor(id); - store_value_with_data_type(out_ptr, value, tensor.data_type()); - } - }); -} - -template -void AssetsLibrary::fill(T &&tensor, D &&distribution, std::random_device::result_type seed_offset) const -{ - Window window; - for(unsigned int d = 0; d < tensor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, tensor.shape()[d], 1)); - } - - std::mt19937 gen(_seed + seed_offset); - - //FIXME: Replace with normal loop - execute_window_loop(window, [&](const Coordinates & id) - { - using ResultType = typename std::remove_reference::type::result_type; - const ResultType value = distribution(gen); - void *const out_ptr = tensor(id); - store_value_with_data_type(out_ptr, value, tensor.data_type()); - }); - - fill_borders_with_garbage(tensor, distribution, seed_offset); -} - -template -void AssetsLibrary::fill(RawTensor &raw, D &&distribution, std::random_device::result_type seed_offset) const -{ - std::mt19937 gen(_seed + seed_offset); - - for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) - { - using ResultType = typename std::remove_reference::type::result_type; - const ResultType value = distribution(gen); - store_value_with_data_type(raw.data() + offset, value, raw.data_type()); - } -} - -template -void AssetsLibrary::fill(T &&tensor, const std::string &name, Format format) const -{ - const RawTensor &raw = get(name, format); - - for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) - { - const Coordinates id = index2coord(raw.shape(), offset / raw.element_size()); - - const RawTensor::value_type *const raw_ptr = raw.data() + offset; - const auto out_ptr = static_cast(tensor(id)); - std::copy_n(raw_ptr, raw.element_size(), out_ptr); - } -} - -template -void AssetsLibrary::fill(T &&tensor, const std::string &name, Channel channel) const -{ - fill(std::forward(tensor), name, get_format_for_channel(channel), channel); -} - -template -void AssetsLibrary::fill(T &&tensor, const std::string &name, Format format, Channel channel) const -{ - const RawTensor &raw = get(name, format, channel); - - for(size_t offset = 0; offset < raw.size(); offset += raw.element_size()) - { - const Coordinates id = index2coord(raw.shape(), offset / raw.element_size()); - - const RawTensor::value_type *const raw_ptr = raw.data() + offset; - const auto out_ptr = static_cast(tensor(id)); - std::copy_n(raw_ptr, raw.element_size(), out_ptr); - } -} - -template -void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset) const -{ - switch(tensor.data_type()) - { - case DataType::U8: - { - std::uniform_int_distribution distribution_u8(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_u8, seed_offset); - break; - } - case DataType::S8: - case DataType::QS8: - { - std::uniform_int_distribution distribution_s8(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_s8, seed_offset); - break; - } - case DataType::U16: - { - std::uniform_int_distribution distribution_u16(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_u16, seed_offset); - break; - } - case DataType::S16: - case DataType::QS16: - { - std::uniform_int_distribution distribution_s16(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_s16, seed_offset); - break; - } - case DataType::U32: - { - std::uniform_int_distribution distribution_u32(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_u32, seed_offset); - break; - } - case DataType::S32: - { - std::uniform_int_distribution distribution_s32(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_s32, seed_offset); - break; - } - case DataType::U64: - { - std::uniform_int_distribution distribution_u64(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_u64, seed_offset); - break; - } - case DataType::S64: - { - std::uniform_int_distribution distribution_s64(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_s64, seed_offset); - break; - } - case DataType::F16: - { - // It doesn't make sense to check [-inf, inf], so hard code it to a big number - std::uniform_real_distribution distribution_f16(-100.f, 100.f); - fill(tensor, distribution_f16, seed_offset); - break; - } - case DataType::F32: - { - // It doesn't make sense to check [-inf, inf], so hard code it to a big number - std::uniform_real_distribution distribution_f32(-1000.f, 1000.f); - fill(tensor, distribution_f32, seed_offset); - break; - } - case DataType::F64: - { - // It doesn't make sense to check [-inf, inf], so hard code it to a big number - std::uniform_real_distribution distribution_f64(-1000.f, 1000.f); - fill(tensor, distribution_f64, seed_offset); - break; - } - case DataType::SIZET: - { - std::uniform_int_distribution distribution_sizet(std::numeric_limits::lowest(), std::numeric_limits::max()); - fill(tensor, distribution_sizet, seed_offset); - break; - } - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } -} - -template -void AssetsLibrary::fill_tensor_uniform(T &&tensor, std::random_device::result_type seed_offset, D low, D high) const -{ - switch(tensor.data_type()) - { - case DataType::U8: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_u8(low, high); - fill(tensor, distribution_u8, seed_offset); - break; - } - case DataType::S8: - case DataType::QS8: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_s8(low, high); - fill(tensor, distribution_s8, seed_offset); - break; - } - case DataType::U16: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_u16(low, high); - fill(tensor, distribution_u16, seed_offset); - break; - } - case DataType::S16: - case DataType::QS16: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_s16(low, high); - fill(tensor, distribution_s16, seed_offset); - break; - } - case DataType::U32: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_u32(low, high); - fill(tensor, distribution_u32, seed_offset); - break; - } - case DataType::S32: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_s32(low, high); - fill(tensor, distribution_s32, seed_offset); - break; - } - case DataType::U64: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_u64(low, high); - fill(tensor, distribution_u64, seed_offset); - break; - } - case DataType::S64: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_s64(low, high); - fill(tensor, distribution_s64, seed_offset); - break; - } - case DataType::F16: - { - std::uniform_real_distribution distribution_f16(low, high); - fill(tensor, distribution_f16, seed_offset); - break; - } - case DataType::F32: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_real_distribution distribution_f32(low, high); - fill(tensor, distribution_f32, seed_offset); - break; - } - case DataType::F64: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_real_distribution distribution_f64(low, high); - fill(tensor, distribution_f64, seed_offset); - break; - } - case DataType::SIZET: - { - ARM_COMPUTE_ERROR_ON(!(std::is_same::value)); - std::uniform_int_distribution distribution_sizet(low, high); - fill(tensor, distribution_sizet, seed_offset); - break; - } - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } -} - -template -void AssetsLibrary::fill_layer_data(T &&tensor, std::string name) const -{ -#ifdef _WIN32 - const std::string path_separator("\\"); -#else /* _WIN32 */ - const std::string path_separator("/"); -#endif /* _WIN32 */ - - const std::string path = _library_path + path_separator + name; - - // Open file - std::ifstream file(path, std::ios::in | std::ios::binary); - if(!file.good()) - { - throw std::runtime_error("Could not load binary data: " + path); - } - - Window window; - for(unsigned int d = 0; d < tensor.shape().num_dimensions(); ++d) - { - window.set(d, Window::Dimension(0, tensor.shape()[d], 1)); - } - - //FIXME : Replace with normal loop - execute_window_loop(window, [&](const Coordinates & id) - { - float val; - file.read(reinterpret_cast(&val), sizeof(float)); - void *const out_ptr = tensor(id); - store_value_with_data_type(out_ptr, val, tensor.data_type()); - }); -} -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_TENSOR_LIBRARY_H__ */ diff --git a/tests/validation_old/CL/CLFixture.cpp b/tests/validation_old/CL/CLFixture.cpp deleted file mode 100644 index aacaeb35b7..0000000000 --- a/tests/validation_old/CL/CLFixture.cpp +++ /dev/null @@ -1,32 +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_old/CL/CLFixture.h" - -#include "tests/validation_old/boost_wrapper.h" - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -BOOST_GLOBAL_FIXTURE(CLFixture); diff --git a/tests/validation_old/CL/CLFixture.h b/tests/validation_old/CL/CLFixture.h deleted file mode 100644 index 77538be8f4..0000000000 --- a/tests/validation_old/CL/CLFixture.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_VALIDATION_CL_CLFIXTURE_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ - -#include "arm_compute/runtime/CL/CLScheduler.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -struct CLFixture -{ - CLFixture() - { - CLScheduler::get().default_init(); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_CL_CLFIXTURE_H__ */ diff --git a/tests/validation_old/CL/ROIPoolingLayer.cpp b/tests/validation_old/CL/ROIPoolingLayer.cpp deleted file mode 100644 index ec804ccb84..0000000000 --- a/tests/validation_old/CL/ROIPoolingLayer.cpp +++ /dev/null @@ -1,112 +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 "CL/CLAccessor.h" -#include "CL/CLArrayAccessor.h" -#include "arm_compute/runtime/CL/CLArray.h" -#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -CLTensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create tensors - CLTensor src = create_tensor(shape, dt); - CLTensor dst = create_tensor(shape_dst, dt); - - // Create ROI array - CLArray rois_array(rois.size()); - fill_array(CLArrayAccessor(rois_array), rois); - - // Create and configure function - CLROIPoolingLayer roi_pool; - roi_pool.configure(&src, &rois_array, &dst, pool_info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(CLAccessor(src), distribution, 0); - - // Compute function - roi_pool.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * - boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), - dt, num_rois, roi_pool_size, roi_scale) -{ - TensorShape shape(50U, 47U, 2U, 3U); - ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); - - // Construct ROI vector - std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); - - // Compute function - CLTensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); - - // Validate output - validate(CLAccessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Datasets.h b/tests/validation_old/Datasets.h deleted file mode 100644 index 464fffd1cf..0000000000 --- a/tests/validation_old/Datasets.h +++ /dev/null @@ -1,264 +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_DATASETS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ - -#include "tests/validation_old/dataset/ActivationFunctionDataset.h" -#include "tests/validation_old/dataset/BatchNormalizationLayerDataset.h" -#include "tests/validation_old/dataset/BorderModeDataset.h" -#include "tests/validation_old/dataset/ConvertPolicyDataset.h" -#include "tests/validation_old/dataset/ConvolutionLayerDataset.h" -#include "tests/validation_old/dataset/DataTypeDatasets.h" -#include "tests/validation_old/dataset/FullyConnectedLayerDataset.h" -#include "tests/validation_old/dataset/GEMMDataset.h" -#include "tests/validation_old/dataset/ImageDatasets.h" -#include "tests/validation_old/dataset/InterpolationPolicyDataset.h" -#include "tests/validation_old/dataset/MatrixPatternDataset.h" -#include "tests/validation_old/dataset/NonLinearFilterFunctionDataset.h" -#include "tests/validation_old/dataset/NormalizationTypeDataset.h" -#include "tests/validation_old/dataset/PoolingTypesDataset.h" -#include "tests/validation_old/dataset/RoundingPolicyDataset.h" -#include "tests/validation_old/dataset/ShapeDatasets.h" -#include "tests/validation_old/dataset/ThresholdDataset.h" - -#include "tests/validation_old/boost_wrapper.h" - -using namespace boost::unit_test::data::monomorphic; - -namespace boost -{ -namespace unit_test -{ -namespace data -{ -namespace monomorphic -{ -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; - -/// Register the data set with Boost -template <> -struct is_dataset : boost::mpl::true_ -{ -}; -} -} -} -} -#endif /* __ARM_COMPUTE_TEST_VALIDATION_DATASETS_H__ */ diff --git a/tests/validation_old/FixedPoint.h b/tests/validation_old/FixedPoint.h deleted file mode 100644 index 8e1f5a405e..0000000000 --- a/tests/validation_old/FixedPoint.h +++ /dev/null @@ -1,986 +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 "support/ToolchainSupport.h" -#include "tests/Utils.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; }; -// 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"); - - // Friends - friend struct detail::functions; - friend struct detail::constant_expr; - - /** 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._value >> 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - return (x._value == y._value); - } - /** 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - return (x._value > y._value); - } - /** 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - return (x._value >= y._value); - } - /** 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - return (x._value < y._value); - } - /** 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - return (x._value <= y._value); - } - /** 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._value, min, max), x._fixed_point_position, 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._value; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x._fixed_point_position, 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x._value) + static_cast(y._value); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x._value + y._value, 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._fixed_point_position, y._fixed_point_position); - x.rescale(p); - y.rescale(p); - if(OP == OverflowPolicy::SATURATE) - { - using type = typename traits::promote::type; - type val = static_cast(x._value) - static_cast(y._value); - val = constant_expr::saturate_cast(val); - return fixed_point(static_cast(val), p, true); - } - else - { - return fixed_point(x._value - y._value, 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._fixed_point_position, y._fixed_point_position); - uint8_t p_max = std::max(x._fixed_point_position, y._fixed_point_position); - promoted_T round_factor = (1 << (p_max - 1)); - promoted_T val = ((static_cast(x._value) * static_cast(y._value)) + 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._fixed_point_position, y._fixed_point_position); - promoted_T denom = static_cast(y._value); - if(denom != 0) - { - promoted_T val = (static_cast(x._value) << std::max(x._fixed_point_position, y._fixed_point_position)) / denom; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), p, true); - } - else - { - T val = (x._value < 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._value) << shift; - if(OP == OverflowPolicy::SATURATE) - { - val = constant_expr::saturate_cast(val); - } - return fixed_point(static_cast(val), x._fixed_point_position, 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._value >> shift, x._fixed_point_position, 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._value < 0) ? constant_expr::saturate_cast(-static_cast(x._value)) : x._value; - return fixed_point(val, x._fixed_point_position, 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._fixed_point_position; - 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._value >> 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._fixed_point_position; - // 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)._value, 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._fixed_point_position; - int8_t shift = std::numeric_limits::digits - (p + detail::clz(x._value)); - - 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._fixed_point_position; - // 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_old/Helpers.h b/tests/validation_old/Helpers.h deleted file mode 100644 index e109edee2a..0000000000 --- a/tests/validation_old/Helpers.h +++ /dev/null @@ -1,273 +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 "tests/Globals.h" -#include "tests/ILutAccessor.h" -#include "tests/Types.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "tests/validation_old/half.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Helper function to fill one or more tensors with the uniform distribution with int values. - * - * @param[in] dist Distribution to be used to get the values for the tensor. - * @param[in] seeds List of seeds to be used to fill each tensor. - * @param[in,out] tensor Tensor to be initialized with the values of the distribution. - * @param[in,out] other_tensors (Optional) One or more tensors to be filled. - * - */ -template -void fill_tensors(D &&dist, std::initializer_list seeds, T &&tensor, Ts &&... other_tensors) -{ - const std::array < T, 1 + sizeof...(Ts) > tensors{ { std::forward(tensor), std::forward(other_tensors)... } }; - std::vector vs(seeds); - ARM_COMPUTE_ERROR_ON(vs.size() != tensors.size()); - int k = 0; - for(auto tp : tensors) - { - library->fill(*tp, std::forward(dist), vs[k++]); - } -} - -/** Helper function to get the testing range for each activation layer. - * - * @param[in] activation Activation function to test. - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. - * - * @return A pair containing the lower upper testing bounds for a given function. - */ -template -inline std::pair get_activation_layer_test_bounds(ActivationLayerInfo::ActivationFunction activation, int fixed_point_position = 1) -{ - bool is_float = std::is_same::value; - is_float = is_float || std::is_same::value; - - std::pair bounds; - - // Set initial values - if(is_float) - { - bounds = std::make_pair(-255.f, 255.f); - } - else - { - bounds = std::make_pair(std::numeric_limits::lowest(), std::numeric_limits::max()); - } - - // Reduce testing ranges - switch(activation) - { - case ActivationLayerInfo::ActivationFunction::LOGISTIC: - case ActivationLayerInfo::ActivationFunction::SOFT_RELU: - // Reduce range as exponent overflows - if(is_float) - { - bounds.first = -40.f; - bounds.second = 40.f; - } - else - { - bounds.first = -(1 << (fixed_point_position)); - bounds.second = 1 << (fixed_point_position); - } - break; - case ActivationLayerInfo::ActivationFunction::TANH: - // Reduce range as exponent overflows - if(!is_float) - { - bounds.first = -(1 << (fixed_point_position)); - bounds.second = 1 << (fixed_point_position); - } - break; - case ActivationLayerInfo::ActivationFunction::SQRT: - // Reduce range as sqrt should take a non-negative number - bounds.first = (is_float) ? 0 : 1; - break; - default: - break; - } - return bounds; -} -/** Helper function to get the testing range for batch normalization layer. - * - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part. Defaults to 1. - * - * @return A pair containing the lower upper testing bounds. - */ -template -std::pair get_batchnormalization_layer_test_bounds(int fixed_point_position = 1) -{ - bool is_float = std::is_floating_point::value; - std::pair bounds; - - // Set initial values - if(is_float) - { - bounds = std::make_pair(-1.f, 1.f); - } - else - { - bounds = std::make_pair(1, 1 << (fixed_point_position)); - } - - return bounds; -} - -/** Fill mask with the corresponding given pattern. - * - * @param[in,out] mask Mask to be filled according to pattern - * @param[in] cols Columns (width) of mask - * @param[in] rows Rows (height) of mask - * @param[in] pattern Pattern to fill the mask according to - */ -inline void fill_mask_from_pattern(uint8_t *mask, int cols, int rows, MatrixPattern pattern) -{ - unsigned int v = 0; - std::mt19937 gen(user_config.seed.get()); - std::bernoulli_distribution dist(0.5); - - for(int r = 0; r < rows; ++r) - { - for(int c = 0; c < cols; ++c, ++v) - { - uint8_t val = 0; - - switch(pattern) - { - case MatrixPattern::BOX: - val = 255; - break; - case MatrixPattern::CROSS: - val = ((r == (rows / 2)) || (c == (cols / 2))) ? 255 : 0; - break; - case MatrixPattern::DISK: - val = (((r - rows / 2.0f + 0.5f) * (r - rows / 2.0f + 0.5f)) / ((rows / 2.0f) * (rows / 2.0f)) + ((c - cols / 2.0f + 0.5f) * (c - cols / 2.0f + 0.5f)) / ((cols / 2.0f) * - (cols / 2.0f))) <= 1.0f ? 255 : 0; - break; - case MatrixPattern::OTHER: - val = (dist(gen) ? 0 : 255); - break; - default: - return; - } - - mask[v] = val; - } - } - - if(pattern == MatrixPattern::OTHER) - { - std::uniform_int_distribution distribution_u8(0, ((cols * rows) - 1)); - mask[distribution_u8(gen)] = 255; - } -} - -/** 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. - */ -inline TensorShape calculate_depth_concatenate_shape(std::vector input_shapes) -{ - TensorShape out_shape = input_shapes.at(0); - - unsigned int max_x = 0; - unsigned int max_y = 0; - unsigned int depth = 0; - - for(auto const &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; -} - -/** Fill matrix random. - * - * @param[in,out] matrix Matrix - * @param[in] cols Columns (width) of matrix - * @param[in] rows Rows (height) of matrix - */ -template -inline void fill_warp_matrix(std::array &matrix, int cols, int rows) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_real_distribution dist(-1, 1); - - for(int v = 0, r = 0; r < rows; ++r) - { - for(int c = 0; c < cols; ++c, ++v) - { - matrix[v] = dist(gen); - } - } - if(SIZE == 9) - { - matrix[(cols * rows) - 1] = 1; - } -} - -/** Helper function to fill the Lut random by a ILutAccessor. - * - * @param[in,out] table Accessor at the Lut. - * - */ -template -void fill_lookuptable(T &&table) -{ - std::mt19937 generator(user_config.seed.get()); - std::uniform_int_distribution distribution(std::numeric_limits::min(), std::numeric_limits::max()); - - for(int i = std::numeric_limits::min(); i <= std::numeric_limits::max(); i++) - { - table[i] = distribution(generator); - } -} -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_HELPERS_H__ */ diff --git a/tests/validation_old/NEON/AbsoluteDifference.cpp b/tests/validation_old/NEON/AbsoluteDifference.cpp deleted file mode 100644 index cde0b46268..0000000000 --- a/tests/validation_old/NEON/AbsoluteDifference.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAbsoluteDifference.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon absolute difference function. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * - * @return Computed output tensor. - */ -Tensor compute_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt_in0); - Tensor src2 = create_tensor(shape, dt_in1); - Tensor dst = create_tensor(shape, dt_out); - - // Create and configure function - NEAbsoluteDifference abs_d; - abs_d.configure(&src1, &src2, &dst); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - - // Compute function - abs_d.run(); - - return dst; -} - -void validate_configuration(const Tensor &src1, const Tensor &src2, Tensor &dst, TensorShape shape) -{ - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAbsoluteDifference abs_d; - abs_d.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); -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AbsoluteDifference) - -BOOST_AUTO_TEST_SUITE(U8) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), - shape) -{ - // Create tensors - Tensor src1 = create_tensor(shape, DataType::U8); - Tensor src2 = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - validate_configuration(src1, src2, dst, shape); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), - shape) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), - shape) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, DataType::U8, DataType::U8, DataType::U8); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(S16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Create tensors - Tensor src1 = create_tensor(shape, dt); - Tensor src2 = create_tensor(shape, DataType::S16); - Tensor dst = create_tensor(shape, DataType::S16); - - validate_configuration(src1, src2, dst, shape); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ DataType::U8, DataType::S16 }), - shape, dt) -{ - // Compute function - Tensor dst = compute_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_absolute_difference(shape, dt, DataType::S16, DataType::S16); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Accumulate.cpp b/tests/validation_old/NEON/Accumulate.cpp deleted file mode 100644 index a173338542..0000000000 --- a/tests/validation_old/NEON/Accumulate.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate(const TensorShape &shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - // Create and configure function - NEAccumulate acc; - acc.configure(&src, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Accumulate) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()), - shape) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulate acc; - acc.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); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), - shape) -{ - // Compute function - Tensor dst = compute_accumulate(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), - shape) -{ - // Compute function - Tensor dst = compute_accumulate(shape); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate(shape); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/AccumulateSquared.cpp b/tests/validation_old/NEON/AccumulateSquared.cpp deleted file mode 100644 index f4eea7d764..0000000000 --- a/tests/validation_old/NEON/AccumulateSquared.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate squared function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate_squared(const TensorShape &shape, uint32_t shift) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - // Create and configure function - NEAccumulateSquared acc; - acc.configure(&src, shift, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - // dst tensor filled with non-negative values - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1, static_cast(0), std::numeric_limits::max()); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AccumulateSquared) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::xrange(0U, 16U), - shape, shift) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::S16); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulateSquared acc; - acc.configure(&src, shift, &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); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::xrange(0U, 16U), - shape, shift) -{ - // Compute function - Tensor dst = compute_accumulate_squared(shape, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0U, 1U, 15U }), - shape, shift) -{ - // Compute function - Tensor dst = compute_accumulate_squared(shape, shift); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_squared(shape, shift); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/AccumulateWeighted.cpp b/tests/validation_old/NEON/AccumulateWeighted.cpp deleted file mode 100644 index 758e437338..0000000000 --- a/tests/validation_old/NEON/AccumulateWeighted.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEAccumulate.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -/** Compute Neon accumulate weighted function. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed output tensor. - */ -Tensor compute_accumulate_weighted(const TensorShape &shape, float alpha) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - // Create and configure function - NEAccumulateWeighted acc; - acc.configure(&src, alpha, &dst); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - library->fill_tensor_uniform(Accessor(dst), 1); - - // Compute function - acc.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(AccumulateWeighted) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Create tensors - Tensor src = create_tensor(shape, DataType::U8); - Tensor dst = create_tensor(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEAccumulateWeighted acc; - acc.configure(&src, alpha, &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); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Compute function - Tensor dst = compute_accumulate_weighted(shape, alpha); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ 0.f, 0.5f, 1.f }), - shape, alpha) -{ - // Compute function - Tensor dst = compute_accumulate_weighted(shape, alpha); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_accumulate_weighted(shape, alpha); - - // Validate output - validate(Accessor(dst), ref_dst); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/ROIPoolingLayer.cpp b/tests/validation_old/NEON/ROIPoolingLayer.cpp deleted file mode 100644 index a8d5637412..0000000000 --- a/tests/validation_old/NEON/ROIPoolingLayer.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "NEON/Accessor.h" -#include "NEON/ArrayAccessor.h" -#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include -#include - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -Tensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, ROIPoolingLayerInfo pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create tensors - Tensor src = create_tensor(shape, dt); - Tensor dst = create_tensor(shape_dst, dt); - - // Create ROI array - Array rois_array(rois.size()); - fill_array(ArrayAccessor(rois_array), rois); - - // Create and configure function - NEROIPoolingLayer roi_pool; - roi_pool.configure(&src, &rois_array, &dst, pool_info); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(Accessor(src), distribution, 0); - - // Compute function - roi_pool.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(ROIPoolingLayer) - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, CNNFloatDataTypes() * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) * boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }), - dt, num_rois, roi_pool_size, roi_scale) -{ - TensorShape shape(50U, 47U, 2U, 3U); - ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale); - - // Construct ROI vector - std::vector rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed); - - // Compute function - Tensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info); - - // Validate output - validate(Accessor(dst), ref_dst); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/ProgramOptions.cpp b/tests/validation_old/ProgramOptions.cpp deleted file mode 100644 index 96320e80f9..0000000000 --- a/tests/validation_old/ProgramOptions.cpp +++ /dev/null @@ -1,87 +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 "ProgramOptions.h" - -#include "arm_compute/core/Types.h" -#include "tests/TypeReader.h" -#include "utils/TypePrinter.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -ProgramOptions::ProgramOptions() -{ - boost::program_options::options_description generic("Generic options"); - generic.add_options()("help", "Print help message")("seed", boost::program_options::value()->default_value(std::random_device()()), "Seed for the tensor library"); - - _visible.add(generic); - - _hidden.add_options()("path", boost::program_options::value(), "Path from where to load the asset/s"); - - _positional.add("path", 1); -} - -void ProgramOptions::add_options(const boost::program_options::options_description &options) -{ - _visible.add(options); -} - -bool ProgramOptions::wants_help() const -{ - return (_vm.count("help") != 0); -} - -std::string ProgramOptions::get_help() const -{ - std::stringstream help; - help << _visible; - - return help.str(); -} - -void ProgramOptions::parse_commandline(int argc, char **argv) -{ - boost::program_options::options_description all; - all.add(_visible).add(_hidden); - - boost::program_options::store(boost::program_options::command_line_parser(argc, argv) - .options(all) - .positional(_positional) - .allow_unregistered() - .run(), - _vm); - - if(_vm.count("help") == 0 && _vm.count("path") == 0) - { - throw boost::program_options::required_option("PATH"); - } - - boost::program_options::notify(_vm); -} -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/ProgramOptions.h b/tests/validation_old/ProgramOptions.h deleted file mode 100644 index 0b28355aa6..0000000000 --- a/tests/validation_old/ProgramOptions.h +++ /dev/null @@ -1,101 +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_PROGRAM_OPTIONS_H__ -#define __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#include "boost/program_options.hpp" -#pragma GCC diagnostic pop - -#include -#include - -namespace arm_compute -{ -namespace test -{ -/** Defines available commandline arguments and allows to parse them. */ -class ProgramOptions -{ -public: - /** Defines available options. */ - ProgramOptions(); - - /** Signals if the --help flag has been passed on the commandline. */ - bool wants_help() const; - - /** Returns a string describing all available options. */ - std::string get_help() const; - - /** Parses the given arguments and makes them available via @ref get. - * - * @param[in] argc Number of command line arguments. - * @param[in] argv Pointer to the command line arguments. - */ - void parse_commandline(int argc, char **argv); - - /** Sets @p value if it has been specified on the command line. - * - * @note The type T has to match the type that has been specified for the - * command line option. - * - * @param[in] name Name of the option to query. - * @param[out] value Variable to which the value will be assigned. - * - * @return True if the value is assigned, false otherwise. - */ - template - bool get(const std::string &name, T &value) const; - -protected: - /** Allows subclasses to add more specific options - * - * @param[in] options Boost object containing options and their descriptions - */ - void add_options(const boost::program_options::options_description &options); - -private: - boost::program_options::options_description _hidden{}; - boost::program_options::options_description _visible{ "Configuration options" }; - boost::program_options::positional_options_description _positional{}; - boost::program_options::variables_map _vm{}; -}; - -template -bool ProgramOptions::get(const std::string &name, T &value) const -{ - if(_vm.count(name) != 0) - { - value = _vm[name].as(); - return true; - } - - return false; -} -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_PROGRAM_OPTIONS_H__ */ diff --git a/tests/validation_old/RawTensor.cpp b/tests/validation_old/RawTensor.cpp deleted file mode 100644 index bc2747d2a1..0000000000 --- a/tests/validation_old/RawTensor.cpp +++ /dev/null @@ -1,67 +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 "RawTensor.h" - -namespace arm_compute -{ -namespace test -{ -RawTensor::RawTensor(TensorShape shape, Format format, int fixed_point_position) - : SimpleTensor(shape, format, fixed_point_position) -{ - _buffer = support::cpp14::make_unique(SimpleTensor::num_elements() * SimpleTensor::num_channels() * SimpleTensor::element_size()); -} - -RawTensor::RawTensor(TensorShape shape, DataType data_type, int num_channels, int fixed_point_position) - : SimpleTensor(shape, data_type, num_channels, fixed_point_position) -{ - _buffer = support::cpp14::make_unique(SimpleTensor::num_elements() * SimpleTensor::num_channels() * SimpleTensor::element_size()); -} - -RawTensor::RawTensor(const RawTensor &tensor) - : SimpleTensor(tensor.shape(), tensor.data_type(), tensor.num_channels(), tensor.fixed_point_position()) -{ - _format = tensor.format(); - _buffer = support::cpp14::make_unique(num_elements() * num_channels() * element_size()); - std::copy_n(tensor.data(), num_elements() * num_channels() * element_size(), _buffer.get()); -} - -RawTensor &RawTensor::operator=(RawTensor tensor) -{ - swap(*this, tensor); - - return *this; -} - -const void *RawTensor::operator()(const Coordinates &coord) const -{ - return _buffer.get() + coord2index(_shape, coord) * element_size(); -} - -void *RawTensor::operator()(const Coordinates &coord) -{ - return _buffer.get() + coord2index(_shape, coord) * element_size(); -} -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/RawTensor.h b/tests/validation_old/RawTensor.h deleted file mode 100644 index fd0ab2b9fd..0000000000 --- a/tests/validation_old/RawTensor.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. - */ -#ifndef __ARM_COMPUTE_TEST_RAW_TENSOR_H__ -#define __ARM_COMPUTE_TEST_RAW_TENSOR_H__ - -#include "tests/SimpleTensor.h" - -namespace arm_compute -{ -namespace test -{ -/** Subclass of SimpleTensor using uint8_t as value type. - * - * Access operations (except for operator[]) will be based on the data type to - * copy the right number of elements. - */ -class RawTensor : public SimpleTensor -{ -public: - /** Create an uninitialised tensor of the given @p shape and @p format. - * - * @param[in] shape Shape of the new raw tensor. - * @param[in] format Format of the new raw tensor. - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers - */ - RawTensor(TensorShape shape, Format format, int fixed_point_position = 0); - - /** Create an uninitialised tensor of the given @p shape and @p data type. - * - * @param[in] shape Shape of the new raw tensor. - * @param[in] data_type Data type of the new raw tensor. - * @param[in] num_channels (Optional) Number of channels (default = 1). - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers (default = 0). - */ - RawTensor(TensorShape shape, DataType data_type, int num_channels = 1, int fixed_point_position = 0); - - /** Create a deep copy of the given @p tensor. - * - * @param[in] tensor To be copied tensor. - */ - RawTensor(const RawTensor &tensor); - - RawTensor &operator =(RawTensor tensor); - RawTensor(RawTensor &&) = default; - ~RawTensor() = default; - - /** Read only access to the specified element. - * - * @param[in] coord Coordinates of the desired element. - * - * @return A pointer to the desired element. - */ - const void *operator()(const Coordinates &coord) const override; - - /** Access to the specified element. - * - * @param[in] coord Coordinates of the desired element. - * - * @return A pointer to the desired element. - */ - void *operator()(const Coordinates &coord) override; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_RAW_TENSOR_H__ */ diff --git a/tests/validation_old/Reference.cpp b/tests/validation_old/Reference.cpp deleted file mode 100644 index c76d429067..0000000000 --- a/tests/validation_old/Reference.cpp +++ /dev/null @@ -1,156 +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 "Reference.h" - -#include "Helpers.h" -#include "ReferenceCPP.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Helpers.h" - -#include -#include - -using namespace arm_compute::test; - -#ifndef DOXYGEN_SKIP_THIS -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -KeyPointArray Reference::compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, Format::U8); - RawTensor raw_Gx(shape, (gradient_size == 7) ? Format::S32 : Format::S16); - RawTensor raw_Gy(shape, (gradient_size == 7) ? Format::S32 : Format::S16); - RawTensor raw_candidates(shape, Format::F32); - RawTensor raw_non_maxima(shape, Format::F32); - - KeyPointArray corners(shape.total_size()); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::harris_corners(ref_src, raw_Gx, raw_Gy, raw_candidates, raw_non_maxima, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - - return corners; -} - -RawTensor Reference::compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out) -{ - // Create reference - RawTensor ref_src1(shape, dt_in0); - RawTensor ref_src2(shape, dt_in1); - RawTensor ref_dst(shape, dt_out); - - // Fill reference - library->fill_tensor_uniform(ref_src1, 0); - library->fill_tensor_uniform(ref_src2, 1); - - // Compute reference - ReferenceCPP::absolute_difference(ref_src1, ref_src2, ref_dst); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate(const TensorShape &shape) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::S16); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1); - - // Compute reference - ReferenceCPP::accumulate(ref_src, ref_dst); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::S16); - - // Fill reference - // ref_dst tensor filled with non-negative values - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1, static_cast(0), std::numeric_limits::max()); - - // Compute reference - ReferenceCPP::accumulate_squared(ref_src, ref_dst, shift); - - return ref_dst; -} - -RawTensor Reference::compute_reference_accumulate_weighted(const TensorShape &shape, float alpha) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - library->fill_tensor_uniform(ref_dst, 1); - - // Compute reference - ReferenceCPP::accumulate_weighted(ref_src, ref_dst, alpha); - - return ref_dst; -} - -RawTensor Reference::compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - TensorShape shape_dst; - shape_dst.set(0, pool_info.pooled_width()); - shape_dst.set(1, pool_info.pooled_height()); - shape_dst.set(2, shape.z()); - shape_dst.set(3, rois.size()); - - // Create reference - RawTensor ref_src(shape, dt); - RawTensor ref_dst(shape_dst, dt); - - // Fill reference - std::uniform_real_distribution<> distribution(-1, 1); - library->fill(ref_src, distribution, 0.0); - - // Compute reference - ReferenceCPP::roi_pooling_layer(ref_src, ref_dst, rois, pool_info); - - return ref_dst; -} - -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Reference.h b/tests/validation_old/Reference.h deleted file mode 100644 index 7b4043c466..0000000000 --- a/tests/validation_old/Reference.h +++ /dev/null @@ -1,108 +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_REFERENCE_REFERENCE_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ - -#include "arm_compute/runtime/Array.h" -#include "tests/RawTensor.h" -#include "tests/Types.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Interface for reference implementations. */ -class Reference -{ -public: - /** Compute reference Harris corners. - * - * @param[in] shape Shape of input tensor - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - * @return Computed corners' keypoints. - */ - static KeyPointArray compute_reference_harris_corners(const TensorShape &shape, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference absolute difference. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] dt_in0 Data type of first input tensor. - * @param[in] dt_in1 Data type of second input tensor. - * @param[in] dt_out Data type of the output tensor. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_absolute_difference(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate(const TensorShape &shape); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] shift A uint32_t value within the range of [0, 15] - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate_squared(const TensorShape &shape, uint32_t shift); - /** Compute reference accumulate. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] alpha A float value within the range of [0, 1] - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); - /** Compute reference roi pooling layer. - * - * @param[in] shape Shape of the input tensor. - * @param[in] dt Data type of input and output tensors. - * @param[in] rois Region of interest vector. - * @param[in] pool_info ROI Pooling Layer information. - */ - static RawTensor compute_reference_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); - -protected: - Reference() = default; - ~Reference() = default; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_H__ */ diff --git a/tests/validation_old/ReferenceCPP.cpp b/tests/validation_old/ReferenceCPP.cpp deleted file mode 100644 index 4d6141a383..0000000000 --- a/tests/validation_old/ReferenceCPP.cpp +++ /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. - */ -#include "ReferenceCPP.h" - -#include "TensorFactory.h" -#include "TensorOperations.h" -#include "TensorVisitors.h" - -#include "arm_compute/core/Coordinates.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorInfo.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/Tensor.h" -#include "utils/TypePrinter.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include -#include -#include -#include - -using namespace arm_compute::test::validation::tensor_visitors; - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Harris corners -void ReferenceCPP::harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || (Gx.data_type() != DataType::S16 && Gx.data_type() != DataType::S32) || (Gy.data_type() != DataType::S16 && Gy.data_type() != DataType::S32) - || candidates.data_type() != DataType::F32 || non_maxima.data_type() != DataType::F32); - - Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor c(candidates.shape(), candidates.data_type(), candidates.fixed_point_position(), const_cast(reinterpret_cast(candidates.data()))); // NOLINT - Tensor nm(non_maxima.shape(), non_maxima.data_type(), non_maxima.fixed_point_position(), const_cast(reinterpret_cast(non_maxima.data()))); // NOLINT - - if(gradient_size == 7) - { - Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); - Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); - tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - } - else - { - Tensor gx(Gx.shape(), Gx.data_type(), Gx.fixed_point_position(), reinterpret_cast(Gx.data())); - Tensor gy(Gy.shape(), Gy.data_type(), Gy.fixed_point_position(), reinterpret_cast(Gy.data())); - tensor_operations::harris_corners(s, gx, gy, c, nm, threshold, min_dist, sensitivity, gradient_size, block_size, corners, border_mode, constant_border_value); - } -} - -// Absolute difference -void ReferenceCPP::absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(absolute_difference_visitor(), s1, s2, d); -} - -// Integral image -void ReferenceCPP::integral_image(const RawTensor &src, RawTensor &dst) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U32); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::integral_image(s, d); -} - -// Accumulate -void ReferenceCPP::accumulate(const RawTensor &src, RawTensor &dst) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate(s, d); -} - -// Accumulate squared -void ReferenceCPP::accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::S16); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate_squared(s, d, shift); -} - -// Accumulate weighted -void ReferenceCPP::accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::accumulate_weighted(s, d, alpha); -} - -// Non linear filter -void ReferenceCPP::non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::non_linear_filter(s, d, function, mask_size, pattern, mask, border_mode, constant_border_value); -} - -// Threshold -void ReferenceCPP::threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast(src.data())); - Tensor d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast(dst.data())); - tensor_operations::threshold(s, d, threshold, false_value, true_value, type, upper); -} - -// ROI Pooling Layer -void ReferenceCPP::roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - const TensorVariant s = TensorFactory::get_tensor(src); - TensorVariant d = TensorFactory::get_tensor(dst); - boost::apply_visitor(tensor_visitors::roi_pooling_layer_visitor(s, rois, pool_info), d); -} - -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/ReferenceCPP.h b/tests/validation_old/ReferenceCPP.h deleted file mode 100644 index 79d0d698d6..0000000000 --- a/tests/validation_old/ReferenceCPP.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_REFERENCE_REFERENCE_CPP_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ - -#include "RawTensor.h" -#include "Reference.h" - -#include -#include -#include -#include - -namespace arm_compute -{ -class Tensor; - -namespace test -{ -namespace validation -{ -/** C++ reference implementation. */ -class ReferenceCPP final : public Reference -{ -public: - /** Function to compute reference Harris corners. - * - * @param[in] src Input tensor - * @param[in] Gx Tensor used to compute Sobel along the x axis - * @param[in] Gy Tensor used to compute Sobel along the y axis - * @param[in] candidates Tensor used to store candidate corners - * @param[in] non_maxima Tensor used to store non_maxima suppressed candidate corners - * @param[in] threshold Minimum threshold with which to eliminate Harris Corner scores (computed using the normalized Sobel kernel). - * @param[in] min_dist Radial Euclidean distance for the euclidean distance stage - * @param[in] sensitivity Sensitivity threshold k from the Harris-Stephens equation - * @param[in] gradient_size The gradient window size to use on the input. The implementation supports 3, 5, and 7 - * @param[in] block_size The block window size used to compute the Harris Corner score. The implementation supports 3, 5, and 7. - * @param[out] corners Array of keypoints to store the results. - * @param[in] border_mode Border mode to use - * @param[in] constant_border_value Constant value to use for borders if border_mode is set to CONSTANT. - * - */ - static void harris_corners(RawTensor &src, RawTensor &Gx, RawTensor &Gy, const RawTensor &candidates, const RawTensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute the integral image of a tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - */ - static void integral_image(const RawTensor &src, RawTensor &dst); - /** Function to compute the absolute difference between two tensors. - * - * @param[in] src1 First tensor. - * @param[in] src2 Second tensor. - * @param[out] dst Result tensor. - */ - static void absolute_difference(const RawTensor &src1, const RawTensor &src2, RawTensor &dst); - /** Function to accumulate an input tensor into an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - */ - static void accumulate(const RawTensor &src, RawTensor &dst); - /** Function to accumulate a squared value from an input tensor to an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - * @param[in] shift A uint32_t value within the range of [0, 15] - */ - static void accumulate_squared(const RawTensor &src, RawTensor &dst, uint32_t shift); - /** Function to accumulate a weighted value from an input tensor to an output tensor. - * - * @param[in] src Input tensor. - * @param[in, out] dst Result tensor. - * @param[in] alpha A float value within the range of [0, 1] - */ - static void accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha); - /** Compute non linear filter function. - * - * @param[in] src First input tensor - * @param[out] dst Output tensor - * @param[in] function Non linear function to perform - * @param[in] mask_size Mask size. Supported sizes: 3, 5 - * @param[in] pattern Matrix pattern - * @param[in] mask The given mask. - * @param[in] border_mode Strategy to use for borders. - * @param[in] constant_border_value (Optional) Constant value to use for borders if border_mode is set to CONSTANT. - */ - static void non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value = 0); - /** Threshold of@p src to @p dst - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] threshold Threshold. When the threhold type is RANGE, this is used as the lower threshold. - * @param[in] false_value value to set when the condition is not respected. - * @param[in] true_value value to set when the condition is respected. - * @param[in] type Thresholding type. Either RANGE or BINARY. - * @param[in] upper Upper threshold. Only used when the thresholding type is RANGE. - */ - static void threshold(const RawTensor &src, RawTensor &dst, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper); - /** ROI Pooling layer of @p src based on the information from @p pool_info and @p rois. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] rois Region of Interest points. - * @param[in] pool_info ROI Pooling Layer information. - */ - static void roi_pooling_layer(const RawTensor &src, RawTensor &dst, const std::vector &rois, const ROIPoolingLayerInfo &pool_info); - -private: - ReferenceCPP() = delete; - ~ReferenceCPP() = delete; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_REFERENCE_CPP_H__ */ diff --git a/tests/validation_old/SConscript b/tests/validation_old/SConscript deleted file mode 100644 index b401f88b1a..0000000000 --- a/tests/validation_old/SConscript +++ /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. -import SCons -import os.path - -Import('env') -Import('vars') - -# vars is imported from arm_compute: -variables = [ - #FIXME: Remove before release! - BoolVariable("openvx", "Enable OpenVX support in tests", False), - BoolVariable("openblas", "Enable OpenBLAS support in tests", False), - #FIXME Remove before release (And remove all references to INTERNAL_ONLY) - BoolVariable("internal_only", "Enable ARM internal only tests", True), - BoolVariable("pmu", "Enable PMU counters", False), - BoolVariable("validation_tests", "Build validation test programs", True), - BoolVariable("benchmark_tests", "Build benchmark test programs", True) -] - -# We need a separate set of Variables for the Help message (Otherwise the global variables will get displayed twice) -new_options = Variables('scons') - -for v in variables: - new_options.Add(v) - vars.Add(v) - -# Clone the environment to make sure we're not polluting the arm_compute one: -old_validation_env = env.Clone() -vars.Update(old_validation_env) - -Help(new_options.GenerateHelpText(old_validation_env)) - -if old_validation_env['openblas']: - if env['os'] == 'bare_metal': - print("OpenBLAS is not supported on bare metal") - Exit(1) - old_validation_env.Append(CPPDEFINES = ['USE_OPENBLAS']) - old_validation_env.Append(LIBS = ['openblas', 'pthread']) - -if env['os'] in ['android', 'bare_metal'] or env['standalone']: - Import('arm_compute_a') - Import('arm_compute_core_a') - old_validation_env.Append(LIBS = [arm_compute_a, arm_compute_core_a]) - arm_compute_lib = arm_compute_a -else: - Import('arm_compute_so') - old_validation_env.Append(LIBS = ["arm_compute", "arm_compute_core"]) - arm_compute_lib = arm_compute_so - -#FIXME Delete before release -if old_validation_env['internal_only']: - old_validation_env.Append(CPPDEFINES=['INTERNAL_ONLY']) - -old_validation_env.Append(CPPPATH = [".", "#tests", "#3rdparty/include"]) -old_validation_env.Append(LIBPATH = ["#3rdparty/%s/%s" % (env['os'], env['arch'])]) -old_validation_env.Append(LIBPATH = ["#build/%s" % env['build_dir']]) -old_validation_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) -old_validation_env.Append(LIBS = ['boost_program_options']) -old_validation_env.Append(CXXFLAGS = ['-Wno-missing-field-initializers']) -old_validation_env.Append(CPPDEFINES=['BOOST']) -old_validation_env.Append(LIBS = ['boost_unit_test_framework']) - -old_files_validation = Glob('*.cpp') - -# Add unit tests -old_files_validation += Glob('UNIT/*.cpp') -old_files_validation += Glob('UNIT/*/*.cpp') - -if env['opencl']: - Import('opencl') - - old_files_validation += Glob('CL/*.cpp') - old_files_validation += Glob('CL/*/*.cpp') - old_files_validation += Glob('system_tests/CL/*.cpp') - - old_validation_env.Append(LIBS = "OpenCL") - old_validation_env.Append(CPPDEFINES=['ARM_COMPUTE_CL']) - -#FIXME Remove before release -if old_validation_env['openvx']: - old_files_validation += Glob('VX/*.cpp') - old_files_validation += Glob('VX/*/*.cpp') - - old_validation_env.Append(LIBS = ['openvx', 'vxu']) - -if env['neon']: - old_files_validation += Glob('NEON/*.cpp') - old_files_validation += Glob('NEON/*/*.cpp') - old_files_validation += Glob('system_tests/NEON/*.cpp') - -if env['os'] == 'android': - old_validation_env.Append(LIBS = ["log"]) - -if old_validation_env['validation_tests']: - arm_compute_validation_old = old_validation_env.Program('arm_compute_validation_old', old_files_validation) - Depends(arm_compute_validation_old, arm_compute_lib) - if env['opencl']: - Depends(arm_compute_validation_old, opencl) - Default(arm_compute_validation_old) - Export('arm_compute_validation_old') diff --git a/tests/validation_old/Tensor.h b/tests/validation_old/Tensor.h deleted file mode 100644 index 84d76e7143..0000000000 --- a/tests/validation_old/Tensor.h +++ /dev/null @@ -1,118 +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_TENSOR_H__ -#define __ARM_COMPUTE_TEST_TENSOR_H__ - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class Tensor -{ -public: - Tensor() - : _shape(), _dt(DataType::UNKNOWN), _fixed_point_position(0), _ptr(nullptr), _ptr_const(nullptr) {}; - - Tensor(TensorShape shape, DataType dt, int fixed_point_position, T *ptr) - : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(ptr), _ptr_const(nullptr) {}; - - Tensor(TensorShape shape, DataType dt, int fixed_point_position, const T *ptr) - : _shape(shape), _dt(dt), _fixed_point_position(fixed_point_position), _ptr(nullptr), _ptr_const(ptr) {}; - - Tensor(const Tensor &tensor) = delete; - Tensor &operator=(const Tensor &) = delete; - Tensor(Tensor &&) = default; - Tensor &operator=(Tensor &&) = default; - - ~Tensor() = default; - - T &operator[](size_t offset) - { - ARM_COMPUTE_ERROR_ON(_ptr == nullptr); - - return _ptr[offset]; - } - - const T &operator[](size_t offset) const - { - const T *ptr = (_ptr_const != nullptr) ? _ptr_const : _ptr; - - ARM_COMPUTE_ERROR_ON(ptr == nullptr); - - return ptr[offset]; // NOLINT - } - - int num_elements() const - { - return std::accumulate(_shape.cbegin(), _shape.cend(), 1, std::multiplies()); - } - - TensorShape shape() const - { - return _shape; - } - - DataType data_type() const - { - return _dt; - } - - int fixed_point_position() const - { - return _fixed_point_position; - } - - const T *data() const - { - return (_ptr_const != nullptr) ? _ptr_const : _ptr; - } - - T *data() - { - return _ptr; - } - - const T *data_const() const - { - return _ptr_const; - } - -private: - TensorShape _shape; - DataType _dt; - int _fixed_point_position; - T *_ptr; - const T *_ptr_const; -}; -} // namespace validation -} // test -} // arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_H__ */ diff --git a/tests/validation_old/TensorFactory.h b/tests/validation_old/TensorFactory.h deleted file mode 100644 index 3f5b960927..0000000000 --- a/tests/validation_old/TensorFactory.h +++ /dev/null @@ -1,111 +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_TENSOR_FACTORY_H__ -#define __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ - -#include "arm_compute/core/Error.h" -#include "tests/RawTensor.h" -#include "tests/validation_old/Tensor.h" -#include "tests/validation_old/half.h" - -#include "tests/validation_old/boost_wrapper.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -using TensorVariant = boost::variant, Tensor, - Tensor, Tensor, - Tensor, Tensor, - Tensor, - Tensor>; - -/** Helper to create a constant type if the passed reference is constant. */ -template -struct match_const -{ - using type = typename std::conditional::type>::value, const T, T>::type; -}; - -class TensorFactory -{ -public: - template - static TensorVariant get_tensor(R &&raw) - { - TensorVariant v; - DataType dt = raw.data_type(); - int fixed_point_position = raw.fixed_point_position(); - auto shape = raw.shape(); - auto data = raw.data(); - - switch(dt) - { - case DataType::U8: - using value_type_u8 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S8: - case DataType::QS8: - using value_type_s8 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::U16: - using value_type_u16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S16: - case DataType::QS16: - using value_type_s16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::U32: - using value_type_u32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::S32: - using value_type_s32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::F16: - using value_type_f16 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - case DataType::F32: - using value_type_f32 = typename match_const::type; - v = Tensor(shape, dt, fixed_point_position, reinterpret_cast(data)); - break; - default: - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - return v; - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_FACTORY_H__ */ diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h deleted file mode 100644 index e03336505b..0000000000 --- a/tests/validation_old/TensorOperations.h +++ /dev/null @@ -1,687 +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_TENSOR_OPERATIONS_H__ -#define __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ - -#include "arm_compute/core/FixedPoint.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "support/ToolchainSupport.h" -#include "tests/Types.h" -#include "tests/Utils.h" -#include "tests/validation_old/FixedPoint.h" -#include "tests/validation_old/Tensor.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "tests/validation_old/half.h" - -#include -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace tensor_operations -{ -namespace -{ -template -struct is_floating_point - : std::integral_constant < bool, - std::is_same::type>::value || std::is_same::type>::value - || std::is_same::type>::value || std::is_same::type>::value > -{ -}; - -// Return a tensor element at a specified coordinate with different border modes -template -T tensor_elem_at(const Tensor &in, Coordinates coord, BorderMode border_mode, T constant_border_value) -{ - const int x = coord.x(); - const int y = coord.y(); - const int width = static_cast(in.shape().x()); - const int 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)]; -} - -/** Apply 2D spatial filter on a single element of @p in at coordinates @p coord - * - * - filter sizes have to be odd number - * - Row major order of filter assumed - * - TO_ZERO rounding policy assumed - * - SATURATE convert policy assumed - * - */ -template -void apply_2d_spatial_filter(Coordinates coord, const Tensor &in, Tensor &out, const TensorShape &filter_shape, const T2 *filter_itr, float scale, BorderMode border_mode, - T1 constant_border_value = 0) -{ - double val = 0; - const int x = coord.x(); - const int y = coord.y(); - for(int j = y - static_cast(filter_shape[1] / 2); j <= y + static_cast(filter_shape[1] / 2); ++j) - { - for(int i = x - static_cast(filter_shape[0] / 2); i <= x + static_cast(filter_shape[0] / 2); ++i) - { - coord.set(0, i); - coord.set(1, j); - val += static_cast(*filter_itr) * tensor_elem_at(in, coord, border_mode, constant_border_value); - ++filter_itr; - } - } - coord.set(0, x); - coord.set(1, y); - const double rounded_val = support::cpp11::trunc(val * static_cast(scale)); - out[coord2index(in.shape(), coord)] = saturate_cast(rounded_val); -} -} // namespace - -// Sobel 3x3 -template -void sobel_3x3(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { -1, 0, 1, -2, 0, 2, -1, 0, 1 } }; - const std::array sobel_y{ { -1, -2, -1, 0, 0, 0, 1, 2, 1 } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(3U, 3U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(3U, 3U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -// Sobel 5x5 -template -void sobel_5x5(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { - -1, -2, 0, 2, 1, - -4, -8, 0, 8, 4, - -6, -12, 0, 12, 6, - -4, -8, 0, 8, 4, - -1, -2, 0, 2, 1 - } }; - - const std::array sobel_y{ { - -1, -4, -6, -4, -1, - -2, -8, -12, -8, -2, - 0, 0, 0, 0, 0, - 2, 8, 12, 8, 2, - 1, 4, 6, 4, 1 - } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(5U, 5U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(5U, 5U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -// Sobel 7x7 -template -void sobel_7x7(Tensor &in, Tensor &out_x, Tensor &out_y, BorderMode border_mode, uint8_t constant_border_value) -{ - const std::array sobel_x{ { - -1, -4, -5, 0, 5, 4, 1, - -6, -24, -30, 0, 30, 24, 6, - -15, -60, -75, 0, 75, 60, 15, - -20, -80, -100, 0, 100, 80, 20, - -15, -60, -75, 0, 75, 60, 15, - -6, -24, -30, 0, 30, 24, 6, - -1, -4, -5, 0, 5, 4, 1 - } }; - - const std::array sobel_y{ { - -1, -6, -15, -20, -15, -6, -1, - -4, -24, -60, -80, -60, -24, -4, - -5, -30, -75, -100, -75, -30, -5, - 0, 0, 0, 0, 0, 0, 0, - 5, 30, 75, 100, 75, 30, 5, - 4, 24, 60, 80, 60, 24, 4, - 1, 6, 15, 20, 15, 6, 1 - } }; - - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - - apply_2d_spatial_filter(id, in, out_x, TensorShape(7U, 7U), sobel_x.data(), 1.f, border_mode, constant_border_value); - apply_2d_spatial_filter(id, in, out_y, TensorShape(7U, 7U), sobel_y.data(), 1.f, border_mode, constant_border_value); - } -} - -template -void non_maxima_suppression_3x3(Tensor &in, Tensor &out, BorderMode border_mode) -{ - for(int i = 0; i < in.num_elements(); ++i) - { - Coordinates coord = index2coord(in.shape(), i); - int x = coord.x(); - int y = coord.y(); - - if(in[i] >= tensor_elem_at(in, Coordinates(x - 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x, y - 1), border_mode, 0.f) - && in[i] >= tensor_elem_at(in, Coordinates(x + 1, y - 1), border_mode, 0.f) && in[i] >= tensor_elem_at(in, Coordinates(x - 1, y), border_mode, 0.f) - && in[i] > tensor_elem_at(in, Coordinates(x + 1, y), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x - 1, y + 1), border_mode, 0.f) - && in[i] > tensor_elem_at(in, Coordinates(x, y + 1), border_mode, 0.f) && in[i] > tensor_elem_at(in, Coordinates(x + 1, y + 1), border_mode, 0.f)) - { - out[i] = in[i]; - } - else - { - out[i] = 0; - } - } -} - -// Harris corners -template -void harris_corners(Tensor &in, Tensor &Gx, Tensor &Gy, Tensor &candidates, Tensor &non_maxima, float threshold, float min_dist, float sensitivity, - int32_t gradient_size, int32_t block_size, KeyPointArray &corners, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(block_size != 3 && block_size != 5 && block_size != 7); - - ValidRegion valid_region = shape_to_valid_region(candidates.shape()); - float norm_factor = 0.f; - - // Sobel - switch(gradient_size) - { - case 3: - sobel_3x3(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (4 * 255 * block_size); - break; - case 5: - sobel_5x5(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (16 * 255 * block_size); - break; - case 7: - sobel_7x7(in, Gx, Gy, border_mode, constant_border_value); - norm_factor = 1.f / (64 * 255 * block_size); - break; - default: - ARM_COMPUTE_ERROR("Gradient size not supported."); - } - - //Calculate scores - for(int i = 0; i < in.num_elements(); ++i) - { - Coordinates in_coord = index2coord(in.shape(), i); - - float Gx2 = 0; - float Gy2 = 0; - float Gxy = 0; - - // Calculate Gx^2, Gy^2 and Gxy within the given window - for(int y = in_coord.y() - block_size / 2; y <= in_coord.y() + block_size / 2; ++y) - { - for(int x = in_coord.x() - block_size / 2; x <= in_coord.x() + block_size / 2; ++x) - { - Coordinates block_coord(x, y); - - float norm_gx = tensor_elem_at(Gx, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - float norm_gy = tensor_elem_at(Gy, block_coord, border_mode, static_cast(constant_border_value)) * norm_factor; - - Gx2 += std::pow(norm_gx, 2); - Gy2 += std::pow(norm_gy, 2); - Gxy += norm_gx * norm_gy; - } - } - - float trace2 = std::pow(Gx2 + Gy2, 2); - float det = Gx2 * Gy2 - std::pow(Gxy, 2); - float response = det - sensitivity * trace2; - - if(response > threshold) - { - candidates[i] = response; - } - else - { - candidates[i] = 0.f; - } - } - - // Update valid region and remove candidates on borders for border_mode == UNDEFINED - if(border_mode == BorderMode::UNDEFINED) - { - valid_region = shape_to_valid_region(candidates.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2))); - - for(int i = 0; i < candidates.num_elements(); ++i) - { - if(!is_in_valid_region(valid_region, index2coord(candidates.shape(), i))) - { - candidates[i] = 0.f; - } - } - } - - // Suppress non-maxima candidates - non_maxima_suppression_3x3(candidates, non_maxima, border_mode != BorderMode::UNDEFINED ? BorderMode::CONSTANT : BorderMode::UNDEFINED); - if(border_mode == BorderMode::UNDEFINED) - { - valid_region = shape_to_valid_region(non_maxima.shape(), true, BorderSize((gradient_size / 2) + (block_size / 2) + 1)); - } - - // Create vector of candidate corners - KeyPointArray candidates_vector(corners.max_num_values()); - for(int i = 0; i < non_maxima.num_elements(); ++i) - { - Coordinates coord = index2coord(non_maxima.shape(), i); - - if(non_maxima[i] != 0.f && is_in_valid_region(valid_region, coord)) - { - KeyPoint corner; - corner.x = coord.x(); - corner.y = coord.y(); - corner.tracking_status = 1; - corner.strength = non_maxima[i]; - - corner.scale = 0.f; - corner.orientation = 0.f; - corner.error = 0.f; - - candidates_vector.push_back(corner); - } - } - - // If there are any candidates, sort them by strength and add them to the output corners vector if there are no stronger corners within the given euclidean radius - if(candidates_vector.num_values() > 0) - { - std::sort(candidates_vector.buffer(), candidates_vector.buffer() + candidates_vector.num_values(), [](KeyPoint a, KeyPoint b) - { - return a.strength > b.strength; - }); - corners.push_back(candidates_vector.at(0)); - - for(size_t j = 0; j < candidates_vector.num_values(); ++j) - { - bool found = false; - int32_t x = candidates_vector.at(j).x; - int32_t y = candidates_vector.at(j).y; - - for(size_t i = 0; i < corners.num_values(); ++i) - { - int32_t corners_x = corners.at(i).x; - int32_t corners_y = corners.at(i).y; - - // Euclidean distance - if(std::sqrt((std::pow(x - corners_x, 2) + std::pow(y - corners_y, 2))) < min_dist) - { - found = true; - } - } - - // If no stronger corners within the given euclidean radius - if(!found) - { - corners.push_back(candidates_vector.at(j)); - } - } - } -} - -// Integral Image -void integral_image(const Tensor &in, Tensor &out) -{ - // Length of dimensions - const size_t width = in.shape().x(); - const size_t height = in.shape().y(); - const size_t depth = in.shape().z() * in.shape()[3] * in.shape()[4] * in.shape()[5]; - - const size_t image_size = width * height; - - for(size_t z = 0; z < depth; ++z) - { - size_t current_image = z * image_size; - - //First element of each image - out[current_image] = in[current_image]; - - // First row of each image (add only pixel on the left) - for(size_t x = 1; x < width; ++x) - { - out[current_image + x] = static_cast(in[current_image + x]) + out[current_image + x - 1]; - } - - // Subsequent rows - for(size_t y = 1; y < height; ++y) - { - size_t current_row = current_image + (width * y); - - // First element of each row (add only pixel up) - out[current_row] = static_cast(in[current_row]) + out[current_row - width]; - - // Following row elements - for(size_t x = 1; x < width; ++x) - { - size_t current_pixel = current_row + x; - - // out = in + up(out) + left(out) - up_left(out) - out[current_pixel] = static_cast(in[current_pixel]) + out[current_pixel - 1] - + out[current_pixel - width] - out[current_pixel - width - 1]; - } - } - } -} - -// Absolute difference -template -void absolute_difference(const Tensor &in1, const Tensor &in2, Tensor &out) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in1.num_elements(); ++i) - { - intermediate_type val(std::abs(static_cast(in1[i]) - static_cast(in2[i]))); - out[i] = saturate_cast(val); - } -} - -// Accumulate -template -void accumulate(const Tensor &in, Tensor &out) -{ - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in.num_elements(); ++i) - { - intermediate_type val = static_cast(out[i]) + static_cast(in[i]); - out[i] = saturate_cast(val); - } -} - -// Accumulate squared -template -void accumulate_squared(const Tensor &in, Tensor &out, uint32_t shift) -{ - if(shift > 15) - { - ARM_COMPUTE_ERROR("Shift in accumulate_squared must be within the range [0, 15]"); - } - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - intermediate_type denom = 1 << shift; - - for(int i = 0; i < in.num_elements(); ++i) - { - intermediate_type val = static_cast(out[i]) + (static_cast(in[i]) * static_cast(in[i]) / denom); - out[i] = saturate_cast(val); - } -} - -// Accumulate weighted total_size = init_auto_padding(tensor_shape, num_channels, type); -template -void accumulate_weighted(const Tensor &in, Tensor &out, float alpha) -{ - if(alpha < 0.f || alpha > 1.f) - { - ARM_COMPUTE_ERROR("Weight (alpha) specified in accumulate_weighted must be within the range [0, 1]"); - } - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - for(int i = 0; i < in.num_elements(); ++i) - { - double val = (1. - static_cast(alpha)) * static_cast(out[i]) + static_cast(alpha) * static_cast(in[i]); - out[i] = static_cast(val); - } -} - -// Non linear filter -template -void non_linear_filter(const Tensor &in, Tensor &out, NonLinearFilterFunction function, unsigned int mask_size, - MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(pattern == MatrixPattern::OTHER && mask == nullptr); - - using intermediate_type = typename common_promoted_signed_type::intermediate_type; - - const int sq_mask_size = mask_size * mask_size; - const int half_mask_size = mask_size / 2; - std::vector vals(sq_mask_size); - intermediate_type current_value = 0; - - const ValidRegion valid_region = shape_to_valid_region(in.shape(), border_mode == BorderMode::UNDEFINED, BorderSize(half_mask_size)); - - for(int element_idx = 0, count = 0, index = 0; element_idx < in.num_elements(); ++element_idx, count = 0, index = 0) - { - Coordinates id = index2coord(in.shape(), element_idx); - if(is_in_valid_region(valid_region, id)) - { - int idx = id.x(); - int idy = id.y(); - for(int y = idy - half_mask_size; y <= idy + half_mask_size; ++y) - { - for(int x = idx - half_mask_size; x <= idx + half_mask_size; ++x, ++index) - { - id.set(0, x); - id.set(1, y); - current_value = tensor_elem_at(in, id, border_mode, constant_border_value); - - if(mask[index] == 255) - { - vals[count] = static_cast(current_value); - ++count; - } - } - } - std::sort(vals.begin(), vals.begin() + count); - switch(function) - { - case NonLinearFilterFunction::MIN: - out[element_idx] = saturate_cast(vals[0]); - break; - case NonLinearFilterFunction::MAX: - out[element_idx] = saturate_cast(vals[count - 1]); - break; - case NonLinearFilterFunction::MEDIAN: - out[element_idx] = saturate_cast(vals[count / 2]); - break; - default: - ARM_COMPUTE_ERROR("Unsupported NonLinearFilter function."); - } - } - } -} - -// Threshold -template -void threshold(const Tensor &in, Tensor &out, uint8_t threshold, uint8_t false_value, uint8_t true_value, ThresholdType type, uint8_t upper) -{ - switch(type) - { - case ThresholdType::BINARY: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = ((in[i] > threshold) ? true_value : false_value); - } - break; - case ThresholdType::RANGE: - for(int i = 0; i < in.num_elements(); ++i) - { - if(in[i] > upper) - { - out[i] = false_value; - } - else if(in[i] < threshold) - { - out[i] = false_value; - } - else - { - out[i] = true_value; - } - } - break; - default: - ARM_COMPUTE_ERROR("Thresholding type not recognised"); - break; - } -} - -// ROI Pooling layer -template -void roi_pooling_layer(const Tensor &in, Tensor &out, const std::vector &rois, const ROIPoolingLayerInfo &pool_info) -{ - const int num_rois = rois.size(); - const int width_in = in.shape().x(); - const int height_in = in.shape().y(); - const int fms = in.shape().z(); - const int volume_in = width_in * height_in * fms; - const int pool_w = pool_info.pooled_width(); - const int pool_h = pool_info.pooled_height(); - const int volume_out = pool_w * pool_h * fms; - const float roi_scale = pool_info.spatial_scale(); - - // Iterate through all rois - for(int roi_idx = 0; roi_idx < num_rois; ++roi_idx) - { - // Get dimensions of current ROI - const ROI &roi = rois[roi_idx]; - - int batch_id = roi.batch_idx; - int roi_start_x = support::cpp11::round(roi.rect.x * roi_scale); - int roi_start_y = support::cpp11::round(roi.rect.y * roi_scale); - int roi_width = std::max(support::cpp11::round(roi.rect.width * roi_scale), 1.f); - int roi_height = std::max(support::cpp11::round(roi.rect.height * roi_scale), 1.f); - - // Iterate through all channel - for(int fm = 0; fm < fms; ++fm) - { - // Calculate each output pixel - for(int py = 0; py < pool_h; ++py) - { - for(int px = 0; px < pool_w; ++px) - { - int region_start_x = static_cast(std::floor((static_cast(px) / pool_w) * roi_width)); - int region_end_x = static_cast(std::floor((static_cast(px + 1) / pool_w) * roi_width)); - int region_start_y = static_cast(std::floor((static_cast(py) / pool_h) * roi_height)); - int region_end_y = static_cast(std::floor((static_cast(py + 1) / pool_h) * roi_height)); - - region_start_x = std::min(std::max(region_start_x + roi_start_x, 0), width_in); - region_end_x = std::min(std::max(region_end_x + roi_start_x, 0), width_in); - region_start_y = std::min(std::max(region_start_y + roi_start_y, 0), height_in); - region_end_y = std::min(std::max(region_end_y + roi_start_y, 0), height_in); - - // Iterate through each pixel in the pooling region - if((region_end_x <= region_start_x) || (region_end_y <= region_start_y)) - { - out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = 0; - } - else - { - T curr_max = std::numeric_limits::lowest(); - for(int j = region_start_y; j < region_end_y; ++j) - { - for(int i = region_start_x; i < region_end_x; ++i) - { - const auto val = in[batch_id * volume_in + fm * width_in * height_in + j * width_in + i]; - curr_max = std::max(val, curr_max); - } - } - out[roi_idx * volume_out + fm * pool_w * pool_h + py * pool_w + px] = curr_max; - } - } - } - } - } -} - -// Fixed point operations -template -void fixed_point_operation(const Tensor &in, Tensor &out, FixedPointOp op) -{ - int p = in.fixed_point_position(); - switch(op) - { - case FixedPointOp::EXP: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::exp(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::LOG: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::log(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::INV_SQRT: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::inv_sqrt(fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - case FixedPointOp::RECIPROCAL: - for(int i = 0; i < in.num_elements(); ++i) - { - out[i] = fixed_point_arithmetic::div(fixed_point_arithmetic::fixed_point(1, p), fixed_point_arithmetic::fixed_point(in[i], p, true)).raw(); - } - break; - default: - ARM_COMPUTE_ERROR("Fixed point operation not supported"); - break; - } -} - -// Tensor print -template -void print(const Tensor &in, std::ostream &out) -{ - out << "\n"; - for(int i = 0; i < in.num_elements(); ++i) - { - out << in[i] << " "; - } - out << "\n"; -} -} // namespace tensor_operations -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_OPERATIONS_H__ */ diff --git a/tests/validation_old/TensorVisitors.h b/tests/validation_old/TensorVisitors.h deleted file mode 100644 index 72c2ba06a7..0000000000 --- a/tests/validation_old/TensorVisitors.h +++ /dev/null @@ -1,130 +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_TENSOR_VISITORS_H__ -#define __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ - -#include "Tensor.h" -#include "TensorOperations.h" -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Helpers.h" -#include "arm_compute/runtime/Lut.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include -#include -#include -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace tensor_visitors -{ -// Absolute Difference visitor -struct absolute_difference_visitor : public boost::static_visitor<> -{ -public: - template - void operator()(const Tensor &in1, const Tensor &in2, Tensor &out) const - { - tensor_operations::absolute_difference(in1, in2, out); - } -}; - -// ROI Pooling layer -struct roi_pooling_layer_visitor : public boost::static_visitor<> -{ -public: - explicit roi_pooling_layer_visitor(const TensorVariant &in, const std::vector &rois, ROIPoolingLayerInfo pool_info) - : _in(in), _rois(rois), _pool_info(pool_info) - { - } - - template - void operator()(Tensor &out) const - { - const Tensor &in = boost::get>(_in); - tensor_operations::roi_pooling_layer(in, out, _rois, _pool_info); - } - -private: - const TensorVariant &_in; - const std::vector &_rois; - ROIPoolingLayerInfo _pool_info; -}; - -// Fixed Point operations visitor -struct fixed_point_operation_visitor : public boost::static_visitor<> -{ -public: - explicit fixed_point_operation_visitor(const TensorVariant &in, FixedPointOp op) - : _in(in), _op(op) - { - } - - template ::value, int>::type = 0> - void operator()(Tensor &out) const - { - const Tensor &in = boost::get>(_in); - tensor_operations::fixed_point_operation(in, out, _op); - } - template < typename T, typename std::enable_if < !std::is_integral::value, int >::type = 0 > - void operator()(Tensor &out) const - { - ARM_COMPUTE_ERROR("NOT SUPPORTED!"); - } - -private: - const TensorVariant &_in; - FixedPointOp _op; -}; -// Print Tensor visitor -struct print_visitor : public boost::static_visitor<> -{ -public: - explicit print_visitor(std::ostream &out) - : _out(out) - { - } - - template - void operator()(const Tensor &in) const - { - tensor_operations::print(in, _out); - } - -private: - std::ostream &_out; -}; -} // namespace tensor_visitors -} // namespace validation -} // namespace test -} // namespace arm_compute - -#endif /* __ARM_COMPUTE_TEST_TENSOR_VISITORS_H__ */ diff --git a/tests/validation_old/UserConfiguration.cpp b/tests/validation_old/UserConfiguration.cpp deleted file mode 100644 index a24de90468..0000000000 --- a/tests/validation_old/UserConfiguration.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 "UserConfiguration.h" - -#include "ProgramOptions.h" - -#include - -namespace arm_compute -{ -namespace test -{ -UserConfiguration::UserConfiguration(const ProgramOptions &options) -{ - std::random_device::result_type tmp_seed = 0; - if(options.get("seed", tmp_seed)) - { - seed = tmp_seed; - } - - std::string tmp_path; - if(options.get("path", tmp_path)) - { - path = tmp_path; - } - - unsigned int tmp_threads = 0; - if(options.get("threads", tmp_threads)) - { - threads = tmp_threads; - } -} -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/UserConfiguration.h b/tests/validation_old/UserConfiguration.h deleted file mode 100644 index 815da04810..0000000000 --- a/tests/validation_old/UserConfiguration.h +++ /dev/null @@ -1,136 +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_USER_CONFIGURATION_H__ -#define __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/Types.h" - -#include -#include - -namespace arm_compute -{ -namespace test -{ -class ProgramOptions; - -/** Container providing easy access to runtime options provided by the user. */ -struct UserConfiguration -{ -protected: - /** Wrapper around options to store if an option has been set. */ - template - class Option - { - public: - /** Initialise the option to its default (C++) value and mark it as 'not set'. */ - Option(); - - /** Initialise the option to the given @p value and mark it as 'set'. */ - Option(const T &value); - - /** Assign the given @p value and mark it as 'set'. */ - Option &operator=(const T &value); - - /** Query if the option has been set. */ - constexpr bool is_set() const; - - /** Return the underlying value as constant. */ - T get() const; - - /** Return the underlying value. */ - T &get(); - - /** Implicitly return the underlying value. */ - operator T() const; - - private: - T _value; - bool _is_set; - }; - -public: - UserConfiguration() = default; - - /** Initialise the configuration according to the program options. - * - * @param[in] options Parsed command line options. - */ - UserConfiguration(const ProgramOptions &options); - - Option path{}; - Option seed{}; - Option threads{}; -}; - -template -UserConfiguration::Option::Option() - : _value{}, _is_set{ false } -{ -} - -template -UserConfiguration::Option::Option(const T &value) - : _value{ value }, _is_set{ true } -{ -} - -template -UserConfiguration::Option &UserConfiguration::Option::operator=(const T &value) -{ - _value = value; - _is_set = true; - - return *this; -} - -template -constexpr bool UserConfiguration::Option::is_set() const -{ - return _is_set; -} - -template -T UserConfiguration::Option::get() const -{ - ARM_COMPUTE_ERROR_ON(!is_set()); - return _value; -} - -template -T &UserConfiguration::Option::get() -{ - return _value; -} - -template -UserConfiguration::Option::operator T() const -{ - ARM_COMPUTE_ERROR_ON(!is_set()); - return _value; -} -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_USER_CONFIGURATION_H__ */ diff --git a/tests/validation_old/Validation.cpp b/tests/validation_old/Validation.cpp deleted file mode 100644 index da5e874b24..0000000000 --- a/tests/validation_old/Validation.cpp +++ /dev/null @@ -1,477 +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/FixedPoint.h" -#include "arm_compute/core/IArray.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/runtime/Tensor.h" -#include "tests/IAccessor.h" -#include "tests/RawTensor.h" -#include "tests/Utils.h" -#include "tests/validation_old/half.h" -#include "utils/TypePrinter.h" - -#include -#include -#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!"); - } -} - -bool is_equal(double target, double ref, double max_absolute_error = std::numeric_limits::epsilon(), double max_relative_error = 0.0001f) -{ - if(!std::isfinite(target) || !std::isfinite(ref)) - { - return false; - } - - // No need further check if they are equal - if(ref == target) - { - return true; - } - - // Need this check for the situation when the two values close to zero but have different sign - if(std::abs(std::abs(ref) - std::abs(target)) <= max_absolute_error) - { - return true; - } - - double relative_error = 0; - - if(std::abs(target) > std::abs(ref)) - { - relative_error = std::abs((target - ref) / target); - } - else - { - relative_error = std::abs((ref - target) / ref); - } - - return relative_error <= max_relative_error; -} - -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 }; - border_id.set(1, 0); - 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 ref = get_double_data(static_cast(border_value) + channel_offset, tensor.data_type()); - const bool equal = is_equal(target, ref); - - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); - - if(!equal) - { - ++num_mismatches; - } - - ++num_elements; - } -} - -void check_single_element(const Coordinates &id, const IAccessor &tensor, const RawTensor &reference, float tolerance_value, - uint64_t wrap_range, int min_channels, size_t channel_size, int64_t &num_mismatches, int64_t &num_elements) -{ - const auto ptr = static_cast(tensor(id)); - const auto ref_ptr = static_cast(reference(id)); - - // Iterate over all channels within one element - for(int channel = 0; channel < min_channels; ++channel) - { - const size_t channel_offset = channel * channel_size; - const double target = get_double_data(ptr + channel_offset, reference.data_type()); - const double ref = get_double_data(ref_ptr + channel_offset, reference.data_type()); - bool equal = is_equal(target, ref, tolerance_value); - - if(wrap_range != 0 && !equal) - { - equal = is_equal(target, ref, wrap_range - tolerance_value); - } - - if(!equal) - { - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); - ++num_mismatches; - } - ++num_elements; - } -} -} // namespace - -void validate(const arm_compute::ValidRegion ®ion, const arm_compute::ValidRegion &reference) -{ - BOOST_TEST(region.anchor.num_dimensions() == reference.anchor.num_dimensions()); - BOOST_TEST(region.shape.num_dimensions() == reference.shape.num_dimensions()); - - for(unsigned int d = 0; d < region.anchor.num_dimensions(); ++d) - { - BOOST_TEST(region.anchor[d] == reference.anchor[d]); - } - - for(unsigned int d = 0; d < region.shape.num_dimensions(); ++d) - { - BOOST_TEST(region.shape[d] == reference.shape[d]); - } -} - -void validate(const arm_compute::PaddingSize &padding, const arm_compute::PaddingSize &reference) -{ - BOOST_TEST(padding.top == reference.top); - BOOST_TEST(padding.right == reference.right); - BOOST_TEST(padding.bottom == reference.bottom); - BOOST_TEST(padding.left == reference.left); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - // Validate with valid region covering the entire shape - validate(tensor, reference, shape_to_valid_region(tensor.shape()), tolerance_value, tolerance_number, wrap_range); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - BOOST_TEST(tensor.element_size() == reference.element_size()); - BOOST_TEST(tensor.format() == reference.format()); - BOOST_TEST(tensor.data_type() == reference.data_type()); - BOOST_TEST(tensor.num_channels() == reference.num_channels()); - BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - const size_t channel_size = element_size_from_data_type(reference.data_type()); - - // 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)) - { - check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); - } - } - - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches <= absolute_tolerance_number, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); -} - -void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value, float tolerance_number, uint64_t wrap_range) -{ - int64_t num_mismatches = 0; - int64_t num_elements = 0; - - BOOST_TEST(tensor.element_size() == reference.element_size()); - BOOST_TEST(tensor.format() == reference.format()); - BOOST_TEST(tensor.data_type() == reference.data_type()); - BOOST_TEST(tensor.num_channels() == reference.num_channels()); - BOOST_TEST(compare_dimensions(tensor.shape(), reference.shape())); - - const int min_elements = std::min(tensor.num_elements(), reference.num_elements()); - const int min_channels = std::min(tensor.num_channels(), reference.num_channels()); - const size_t channel_size = element_size_from_data_type(reference.data_type()); - - // 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(valid_mask[element_idx] == 1) - { - check_single_element(id, tensor, reference, tolerance_value, wrap_range, min_channels, channel_size, num_mismatches, num_elements); - } - else - { - ++num_elements; - } - } - - const int64_t absolute_tolerance_number = tolerance_number * num_elements; - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches <= absolute_tolerance_number, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches - << "%) mismatched (maximum tolerated " << std::setprecision(2) << tolerance_number << "%)"); -} - -void validate(const IAccessor &tensor, const void *reference_value) -{ - BOOST_TEST_REQUIRE((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 ref = get_double_data(reference_value, tensor.data_type()); - const bool equal = is_equal(target, ref); - - BOOST_TEST_INFO("id = " << id); - BOOST_TEST_INFO("channel = " << channel); - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST_WARN(equal); - - if(!equal) - { - ++num_mismatches; - } - - ++num_elements; - } - } - - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches == 0, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); -} - -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) - { - BOOST_TEST((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); - } - } - } - - const float percent_mismatches = static_cast(num_mismatches) / num_elements * 100.f; - - BOOST_TEST(num_mismatches == 0, - num_mismatches << " values (" << std::setprecision(2) << percent_mismatches << "%) mismatched"); -} - -void validate(std::vector classified_labels, std::vector expected_labels) -{ - ARM_COMPUTE_UNUSED(classified_labels); - ARM_COMPUTE_UNUSED(expected_labels); - BOOST_TEST(expected_labels.size() != 0); - BOOST_TEST(classified_labels.size() == expected_labels.size()); - - for(unsigned int i = 0; i < expected_labels.size(); ++i) - { - BOOST_TEST(classified_labels[i] == expected_labels[i]); - } -} - -void validate(float target, float ref, float tolerance_abs_error, float tolerance_relative_error) -{ - const bool equal = is_equal(target, ref, tolerance_abs_error, tolerance_relative_error); - - BOOST_TEST_INFO("reference = " << std::setprecision(5) << ref); - BOOST_TEST_INFO("target = " << std::setprecision(5) << target); - BOOST_TEST(equal); -} - -void validate(IArray &target, IArray &ref, int64_t tolerance) -{ - int64_t num_mismatches = 0; - - BOOST_TEST_WARN(target.num_values() == ref.num_values()); - - for(size_t i = 0; i < target.num_values(); ++i) - { - KeyPoint *ref_val = std::find_if(ref.buffer(), ref.buffer() + ref.num_values(), [&target, i](KeyPoint key) - { - return key.x == target.at(i).x && key.y == target.at(i).y; - }); - - const KeyPoint &key = target.at(i); - - if((ref_val == ref.buffer() + ref.num_values()) || !(is_equal(key.strength, ref_val->strength) && is_equal(key.scale, ref_val->scale) && is_equal(key.orientation, ref_val->orientation) - && is_equal(key.tracking_status, ref_val->tracking_status) && is_equal(key.error, ref_val->error))) - { - ++num_mismatches; - - BOOST_TEST_WARN(is_equal(key.strength, ref_val->strength)); - BOOST_TEST_WARN(is_equal(key.scale, ref_val->scale)); - BOOST_TEST_WARN(is_equal(key.orientation, ref_val->orientation)); - BOOST_TEST_WARN(is_equal(key.tracking_status, ref_val->tracking_status)); - BOOST_TEST_WARN(is_equal(key.error, ref_val->error)); - } - } - - BOOST_TEST(num_mismatches <= tolerance); -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/Validation.h b/tests/validation_old/Validation.h deleted file mode 100644 index f0630c1d3e..0000000000 --- a/tests/validation_old/Validation.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_REFERENCE_VALIDATION_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ - -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Array.h" -#include "tests/RawTensor.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include - -namespace arm_compute -{ -class Tensor; - -namespace test -{ -class IAccessor; - -namespace validation -{ -template -boost::test_tools::predicate_result compare_dimensions(const Dimensions &dimensions1, const Dimensions &dimensions2) -{ - if(dimensions1.num_dimensions() != dimensions2.num_dimensions()) - { - boost::test_tools::predicate_result result(false); - result.message() << "Different dimensionality [" << dimensions1.num_dimensions() << "!=" << dimensions2.num_dimensions() << "]"; - return result; - } - - for(unsigned int i = 0; i < dimensions1.num_dimensions(); ++i) - { - if(dimensions1[i] != dimensions2[i]) - { - boost::test_tools::predicate_result result(false); - result.message() << "Mismatch in dimension " << i << " [" << dimensions1[i] << "!=" << dimensions2[i] << "]"; - return result; - } - } - - 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. - */ -void validate(const IAccessor &tensor, const RawTensor &reference, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); - -/** 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. - */ -void validate(const IAccessor &tensor, const RawTensor &reference, const ValidRegion &valid_region, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); - -/** Validate tensors with valid mask. - * - * - 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. - */ -void validate(const IAccessor &tensor, const RawTensor &reference, const RawTensor &valid_mask, float tolerance_value = 0.f, float tolerance_number = 0.f, uint64_t wrap_range = 0); - -/** 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 - */ -void validate(float target, float ref, float tolerance_abs_error = std::numeric_limits::epsilon(), float tolerance_relative_error = 0.0001f); - -/** Validate KeyPoint arrays. - * - * - All values should match - */ -void validate(IArray &target, IArray &ref, int64_t tolerance = 0); -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_H__ */ diff --git a/tests/validation_old/ValidationProgramOptions.cpp b/tests/validation_old/ValidationProgramOptions.cpp deleted file mode 100644 index adb8c5ab6c..0000000000 --- a/tests/validation_old/ValidationProgramOptions.cpp +++ /dev/null @@ -1,50 +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 "ValidationProgramOptions.h" - -#include - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#include "boost/program_options.hpp" -#pragma GCC diagnostic pop - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -ValidationProgramOptions::ValidationProgramOptions() -{ - boost::program_options::options_description options("Validation options"); - options.add_options()("runs", boost::program_options::value()->default_value(1), "Repetitions per test"); - options.add_options()("threads", boost::program_options::value()->default_value(std::thread::hardware_concurrency()), "Number of parallel CPU threads"); - add_options(options); -} -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_old/ValidationProgramOptions.h b/tests/validation_old/ValidationProgramOptions.h deleted file mode 100644 index 6b29b807de..0000000000 --- a/tests/validation_old/ValidationProgramOptions.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_VALIDATION_PROGRAM_OPTIONS_H__ -#define __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ - -#include "ProgramOptions.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -/** Subclass of @ref ProgramOptions that adds validation specific options. */ -class ValidationProgramOptions : public ProgramOptions -{ -public: - /** Defines additonal options. */ - ValidationProgramOptions(); -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_VALIDATION_PROGRAM_OPTIONS_H__ */ diff --git a/tests/validation_old/ValidationUserConfiguration.h b/tests/validation_old/ValidationUserConfiguration.h deleted file mode 100644 index a9b8b4fe40..0000000000 --- a/tests/validation_old/ValidationUserConfiguration.h +++ /dev/null @@ -1,42 +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_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ -#define __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ - -#include "UserConfiguration.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -// Validation requires no specific configuration -using ValidationUserConfiguration = UserConfiguration; -} // namespace validation - -extern validation::ValidationUserConfiguration user_config; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_REFERENCE_VALIDATION_USER_CONFIGURATION_H__ */ diff --git a/tests/validation_old/boost_wrapper.h b/tests/validation_old/boost_wrapper.h deleted file mode 100644 index b584e4cd1f..0000000000 --- a/tests/validation_old/boost_wrapper.h +++ /dev/null @@ -1,40 +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. - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverloaded-virtual" -#pragma GCC diagnostic ignored "-Weffc++" -#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" -#pragma GCC diagnostic ignored "-Wunused-variable" -#pragma GCC diagnostic ignored "-Wsign-compare" -#include "boost/test/unit_test.hpp" -#include "boost/variant.hpp" -#include "boost/variant/multivisitors.hpp" -#pragma GCC diagnostic pop - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Weffc++" -#include "boost/test/data/test_case.hpp" -#pragma GCC diagnostic pop - -#include "boost/test/data/monomorphic.hpp" diff --git a/tests/validation_old/dataset/ActivationFunctionDataset.h b/tests/validation_old/dataset/ActivationFunctionDataset.h deleted file mode 100644 index b72cffbcd9..0000000000 --- a/tests/validation_old/dataset/ActivationFunctionDataset.h +++ /dev/null @@ -1,67 +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_DATASET_ACTIVATION_FUNCTION_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ - -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible activation functions. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all activation functions. - */ -class ActivationFunctions final : public GenericDataset -{ -public: - ActivationFunctions() - : GenericDataset - { - ActivationLayerInfo::ActivationFunction::ABS, - ActivationLayerInfo::ActivationFunction::LINEAR, - ActivationLayerInfo::ActivationFunction::LOGISTIC, - ActivationLayerInfo::ActivationFunction::RELU, - ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, - ActivationLayerInfo::ActivationFunction::LEAKY_RELU, - ActivationLayerInfo::ActivationFunction::SOFT_RELU, - ActivationLayerInfo::ActivationFunction::SQRT, - ActivationLayerInfo::ActivationFunction::SQUARE, - ActivationLayerInfo::ActivationFunction::TANH - } - { - } - - ~ActivationFunctions() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ActivationLayerDataset.h b/tests/validation_old/dataset/ActivationLayerDataset.h deleted file mode 100644 index 881e19ff79..0000000000 --- a/tests/validation_old/dataset/ActivationLayerDataset.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_DATASET_ACTIVATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class ActivationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "ActivationLayer"; - ss << "_I" << shape; - ss << "_F_" << info.activation(); - return ss.str(); - } - -public: - TensorShape shape; - ActivationLayerInfo info; -}; - -template -using ActivationLayerDataset = GenericDataset; - -class AlexNetActivationLayerDataset final : public ActivationLayerDataset<5> -{ -public: - AlexNetActivationLayerDataset() - : GenericDataset - { - ActivationLayerDataObject{ TensorShape(55U, 55U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(27U, 27U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(13U, 13U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(13U, 13U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - ActivationLayerDataObject{ TensorShape(4096U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - } - { - } - - ~AlexNetActivationLayerDataset() = default; -}; - -class LeNet5ActivationLayerDataset final : public ActivationLayerDataset<1> -{ -public: - LeNet5ActivationLayerDataset() - : GenericDataset - { - ActivationLayerDataObject{ TensorShape(500U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - } - { - } - - ~LeNet5ActivationLayerDataset() = default; -}; - -class GoogLeNetActivationLayerDataset final : public ActivationLayerDataset<33> -{ -public: - GoogLeNetActivationLayerDataset() - : GenericDataset - { - // conv1/relu_7x7 - ActivationLayerDataObject{ TensorShape(112U, 112U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // conv2/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(56U, 56U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // conv2/relu_3x3 - ActivationLayerDataObject{ TensorShape(56U, 56U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_1x1, inception_3b/relu_pool_proj - ActivationLayerDataObject{ TensorShape(28U, 28U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 - ActivationLayerDataObject{ TensorShape(28U, 28U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(28U, 28U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_3b/relu_3x3 - ActivationLayerDataObject{ TensorShape(28U, 28U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 208U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_5x5 - ActivationLayerDataObject{ TensorShape(14U, 14U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj - ActivationLayerDataObject{ TensorShape(14U, 14U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 112U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 224U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 24U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj - ActivationLayerDataObject{ TensorShape(14U, 14U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4c/relu_3x3, inception_4e/relu_1x1 - ActivationLayerDataObject{ TensorShape(14U, 14U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 144U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 288U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(14U, 14U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_4e/relu_3x3 - ActivationLayerDataObject{ TensorShape(14U, 14U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_1x1 - ActivationLayerDataObject{ TensorShape(7U, 7U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_3x3 - ActivationLayerDataObject{ TensorShape(7U, 7U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj - ActivationLayerDataObject{ TensorShape(7U, 7U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_1x1, inception_5b/relu_3x3 - ActivationLayerDataObject{ TensorShape(7U, 7U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_3x3_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, - // inception_5b/relu_5x5_reduce - ActivationLayerDataObject{ TensorShape(7U, 7U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) } - } - { - } - - ~GoogLeNetActivationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/BatchNormalizationLayerDataset.h b/tests/validation_old/dataset/BatchNormalizationLayerDataset.h deleted file mode 100644 index 3ad1befe33..0000000000 --- a/tests/validation_old/dataset/BatchNormalizationLayerDataset.h +++ /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. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class BatchNormalizationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "BatchNormalizationLayer"; - ss << "_I" << shape0; - ss << "_I" << shape1; - ss << "_I" << epsilon; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &s, const BatchNormalizationLayerDataObject &obj) - { - s << static_cast(obj); - return s; - } - -public: - TensorShape shape0; - TensorShape shape1; - float epsilon; -}; - -template -using BatchNormalizationLayerDataset = GenericDataset; - -class RandomBatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset<3> -{ -public: - RandomBatchNormalizationLayerDataset() - : GenericDataset - { - BatchNormalizationLayerDataObject{ TensorShape(15U, 16U, 2U, 12U), TensorShape(2U), 0.1f }, - BatchNormalizationLayerDataObject{ TensorShape(21U, 11U, 12U, 7U), TensorShape(12U), 0.1f }, - BatchNormalizationLayerDataObject{ TensorShape(7U, 3U, 6U, 11U), TensorShape(6U), 0.1f }, - } - { - } - - ~RandomBatchNormalizationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/BorderModeDataset.h b/tests/validation_old/dataset/BorderModeDataset.h deleted file mode 100644 index d1eb48d3bd..0000000000 --- a/tests/validation_old/dataset/BorderModeDataset.h +++ /dev/null @@ -1,82 +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_BORDER_MODE_DATASET_H__ -#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible border modes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class BorderModes -{ -public: - /** Type of the samples in the data set. */ - using sample = BorderMode; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _modes.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const BorderMode *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _modes.data(); - } - -private: - std::array _modes{ { BorderMode::UNDEFINED, BorderMode::CONSTANT, BorderMode::REPLICATE } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ConvertPolicyDataset.h b/tests/validation_old/dataset/ConvertPolicyDataset.h deleted file mode 100644 index e6e2169ffe..0000000000 --- a/tests/validation_old/dataset/ConvertPolicyDataset.h +++ /dev/null @@ -1,82 +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_DATASETS_CONVERT_POLICY_DATASETS_H__ -#define __ARM_COMPUTE_TEST_DATASETS_CONVERT_POLICY_DATASETS_H__ - -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible convert/overflow policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different convert policies. - */ -class ConvertPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = ConvertPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const ConvertPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { ConvertPolicy::WRAP, ConvertPolicy::SATURATE } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_DATASETS_TEST_CONVERT_POLICY_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ConvolutionLayerDataset.h b/tests/validation_old/dataset/ConvolutionLayerDataset.h deleted file mode 100644 index e612c3ec93..0000000000 --- a/tests/validation_old/dataset/ConvolutionLayerDataset.h +++ /dev/null @@ -1,273 +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_DATASET_CONVOLUTION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "tests/validation_old/dataset/GenericDataset.h" -#include "tests/validation_old/dataset/ShapeDatasets.h" - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Convolution Layer data object */ -class ConvolutionLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "ConvolutionLayer"; - ss << "_I" << src_shape; - ss << "_K" << weights_shape; - ss << "_PS" << info; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const ConvolutionLayerDataObject &obj) - { - os << static_cast(obj); - return os; - } - -public: - TensorShape src_shape; - TensorShape weights_shape; - TensorShape bias_shape; - TensorShape dst_shape; - PadStrideInfo info; -}; - -template -using ConvolutionLayerDataset = GenericDataset; - -/** Data set containing small convolution layer shapes */ -class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset<6> -{ -public: - SmallConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U), TensorShape(16U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0) }, - ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 19U), TensorShape(19U), TensorShape(15U, 15U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U), TensorShape(21U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U), TensorShape(16U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0) }, - ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 3U, 2U, 19U), TensorShape(19U), TensorShape(15U, 16U, 19U, 7U), PadStrideInfo(1, 2, 1, 1) } - } - { - } - - ~SmallConvolutionLayerDataset() = default; -}; - -/** Data set containing direct convolution tensor shapes. */ -class DirectConvolutionShapes final : public ShapeDataset<4> -{ -public: - DirectConvolutionShapes() - : ShapeDataset(TensorShape(3U, 3U, 3U, 2U, 4U, 5U), - TensorShape(32U, 37U, 3U), - TensorShape(64U, 32U, 4U, 2U), - TensorShape(13U, 15U, 8U, 3U)) - { - } -}; - -/** AlexNet's convolution layers tensor shapes. */ -class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset<5> -{ -public: - AlexNetConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, - ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1) } - } - { - } - - ~AlexNetConvolutionLayerDataset() = default; -}; - -/** LeNet5's convolution layers tensor shapes. */ -class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset<2> -{ -public: - LeNet5ConvolutionLayerDataset() - : GenericDataset - { - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0) }, - ConvolutionLayerDataObject{ TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0) }, - } - { - } - - ~LeNet5ConvolutionLayerDataset() = default; -}; - -/** GoogleLeNet v1 convolution layers tensor shapes (Part 1). - * - * @note Dataset is split into two to avoid a register allocation failure produced by clang in Android debug builds. - */ -class GoogLeNetConvolutionLayerDataset1 final : public ConvolutionLayerDataset<32> -{ -public: - GoogLeNetConvolutionLayerDataset1() - : GenericDataset - { - // conv1/7x7_s2 - ConvolutionLayerDataObject{ TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3) }, - // conv2/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // conv2/3x3 - ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3a/1x1 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/3x3 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3a/5x5 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2) }, - // inception_3a/pool_proj - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/1x1, inception_3b/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/3x3 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1) }, - // inception_3b/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_3b/5x5 - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2) }, - // inception_3b/pool_proj - ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4a/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4a/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/3x3_reduce, inception_4d/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4b/5x5_reduce, inception_4c/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4b/5x5, inception_4c/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4c/1x1, inception_4c/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4c/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4d/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4d/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4d/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4d/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, - } - { - } - - ~GoogLeNetConvolutionLayerDataset1() = default; -}; - -/** GoogleLeNet v1 convolution layers tensor shapes (Part 2). */ -class GoogLeNetConvolutionLayerDataset2 final : public ConvolutionLayerDataset<17> -{ -public: - GoogLeNetConvolutionLayerDataset2() - : GenericDataset - { - // inception_4e/1x1 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/3x3 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1) }, - // inception_4e/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_4e/5x5 - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2) }, - // inception_4e/pool_proj - ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/1x1 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/3x3 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1) }, - // inception_5a/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5a/5x5 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) }, - // inception_5a/pool_proj, inception_5b/pool_proj - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/1x1 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/3x3_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/3x3 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1) }, - // inception_5b/5x5_reduce - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0) }, - // inception_5b/5x5 - ConvolutionLayerDataObject{ TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) } - } - { - } - - ~GoogLeNetConvolutionLayerDataset2() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/DataTypeDatasets.h b/tests/validation_old/dataset/DataTypeDatasets.h deleted file mode 100644 index 34fc782b10..0000000000 --- a/tests/validation_old/dataset/DataTypeDatasets.h +++ /dev/null @@ -1,193 +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_DATA_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing data types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different data types. - */ -template -class DataTypes -{ -public: - /** Type of the samples in the data set. */ - using sample = DataType; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _types.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const DataType *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _types.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - DataTypes(Ts &&... types) - : _types{ { types... } } - { - } - - /** Protected destructor to prevent deletion of derived classes through a - * pointer to the base class. - */ - ~DataTypes() = default; - -private: - std::array _types; -}; - -/** Data set containing all data types. */ -class AllDataTypes final : public DataTypes<14> -{ -public: - AllDataTypes() - : DataTypes{ DataType::U8, DataType::S8, DataType::U16, DataType::S16, - DataType::U32, DataType::S32, DataType::U64, DataType::S64, - DataType::F16, DataType::F32, DataType::F64, DataType::SIZET, - DataType::QS8, DataType::QS16 } - { - } - - ~AllDataTypes() = default; -}; - -/** Data set containing all unsigned data types. */ -class UnsignedDataTypes final : public DataTypes<4> -{ -public: - UnsignedDataTypes() - : DataTypes{ DataType::U8, DataType::U16, DataType::U32, DataType::U64 } - { - } - - ~UnsignedDataTypes() = default; -}; - -/** Data set containing all signed data types. */ -class SignedDataTypes final : public DataTypes<4> -{ -public: - SignedDataTypes() - : DataTypes{ DataType::S8, DataType::S16, DataType::S32, DataType::S64 } - { - } - - ~SignedDataTypes() = default; -}; - -/** Data set containing all floating point data types. */ -class FloatDataTypes final : public DataTypes<3> -{ -public: - FloatDataTypes() - : DataTypes{ DataType::F16, DataType::F32, DataType::F64 } - { - } - - ~FloatDataTypes() = default; -}; - -/** Data set containing all fixed point data types. */ -class FixedPointDataTypes final : public DataTypes<2> -{ -public: - FixedPointDataTypes() - : DataTypes{ DataType::QS8, DataType::QS16 } - { - } - - ~FixedPointDataTypes() = default; -}; - -/** Supported CNN float types. */ -class CNNFloatDataTypes final : public DataTypes<1> -{ -public: - CNNFloatDataTypes() - : DataTypes{ DataType::F32 } - { - } - - ~CNNFloatDataTypes() = default; -}; - -/** Supported CNN fixed point types. */ -class CNNFixedPointDataTypes final : public DataTypes<2> -{ -public: - CNNFixedPointDataTypes() - : DataTypes{ DataType::QS8, DataType::QS16 } - { - } - - ~CNNFixedPointDataTypes() = default; -}; - -/** Supported CNN types. */ -class CNNDataTypes final : public DataTypes<2> -{ -public: - CNNDataTypes() - : DataTypes{ DataType::F32, DataType::QS8 } - { - } - - ~CNNDataTypes() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/FullyConnectedLayerDataset.h b/tests/validation_old/dataset/FullyConnectedLayerDataset.h deleted file mode 100644 index 8a8fed8f0f..0000000000 --- a/tests/validation_old/dataset/FullyConnectedLayerDataset.h +++ /dev/null @@ -1,155 +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_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class FullyConnectedLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "FullyConnectedLayer"; - ss << "_I" << src_shape; - ss << "_K" << weights_shape; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const FullyConnectedLayerDataObject &obj) - { - os << static_cast(obj); - return os; - } - -public: - TensorShape src_shape; - TensorShape weights_shape; - TensorShape bias_shape; - TensorShape dst_shape; - bool transpose_weights; - bool are_weights_reshaped; -}; - -template -using FullyConnectedLayerDataset = GenericDataset; - -class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> -{ -public: - SmallFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, true }, - FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, true }, - } - { - } - - ~SmallFullyConnectedLayerDataset() = default; -}; - -class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> -{ -public: - LargeFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, false }, - FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, true }, - FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, true }, - } - { - } - - ~LargeFullyConnectedLayerDataset() = default; -}; - -class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<3> -{ -public: - AlexNetFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, - FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, - FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, - } - { - } - - ~AlexNetFullyConnectedLayerDataset() = default; -}; - -class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset<2> -{ -public: - LeNet5FullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U) }, - FullyConnectedLayerDataObject{ TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U) }, - } - { - } - - ~LeNet5FullyConnectedLayerDataset() = default; -}; - -class GoogLeNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<1> -{ -public: - GoogLeNetFullyConnectedLayerDataset() - : GenericDataset - { - FullyConnectedLayerDataObject{ TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, - } - { - } - - ~GoogLeNetFullyConnectedLayerDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/GEMMDataset.h b/tests/validation_old/dataset/GEMMDataset.h deleted file mode 100644 index ee2a387452..0000000000 --- a/tests/validation_old/dataset/GEMMDataset.h +++ /dev/null @@ -1,220 +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_DATASET_GEMM_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class GEMMDataObject -{ -public: - //Data object used for matrix multiple - //D = alpha * A * B + beta * C; - TensorShape shape_a; - TensorShape shape_b; - TensorShape shape_c; - TensorShape shape_d; - float alpha; - float beta; - - operator std::string() const - { - std::stringstream ss; - ss << "GEMM"; - ss << "_A" << shape_a; - ss << "_B" << shape_b; - ss << "_C" << shape_c; - ss << "_D" << shape_d; - ss << "_alpha" << alpha; - ss << "_beta" << beta; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const GEMMDataObject &obj) - { - os << static_cast(obj); - return os; - } -}; - -class SmallGEMMDataset : public GenericDataset -{ -public: - SmallGEMMDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(21U, 13U), TensorShape(33U, 21U), TensorShape(33U, 13U), TensorShape(33U, 13U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(31U, 1U), TensorShape(23U, 31U), TensorShape(23U, 1U), TensorShape(23U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(38U, 12U), TensorShape(21U, 38U), TensorShape(21U, 12U), TensorShape(21U, 12U), 0.2f, 1.2f }, - GEMMDataObject{ TensorShape(32U, 1U), TensorShape(17U, 32U), TensorShape(17U, 1U), TensorShape(17U, 1U), 0.4f, 0.7f }, - } - { - } - - ~SmallGEMMDataset() = default; -}; - -class LargeGEMMDataset : public GenericDataset -{ -public: - LargeGEMMDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(923U, 429U), TensorShape(871U, 923U), TensorShape(871U, 429U), TensorShape(871U, 429U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1021U, 1U), TensorShape(783U, 1021U), TensorShape(783U, 1U), TensorShape(783U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(681U, 1023U), TensorShape(213U, 681U), TensorShape(213U, 1023U), TensorShape(213U, 1023U), 0.2f, 1.2f }, - GEMMDataObject{ TensorShape(941U, 1U), TensorShape(623U, 941U), TensorShape(623U, 1U), TensorShape(623U, 1U), 0.4f, 0.7f }, - } - { - } - - ~LargeGEMMDataset() = default; -}; - -class GoogLeNetGEMMDataset1 : public GenericDataset -{ -public: - GoogLeNetGEMMDataset1() - : GenericDataset - { - GEMMDataObject{ TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f } - } - { - } - - ~GoogLeNetGEMMDataset1() = default; -}; - -class GoogLeNetGEMMDataset2 : public GenericDataset -{ -public: - GoogLeNetGEMMDataset2() - : GenericDataset - { - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f } - } - { - } - - ~GoogLeNetGEMMDataset2() = default; -}; - -class MatrixMultiplyDataset : public GenericDataset -{ -public: - MatrixMultiplyDataset() - : GenericDataset - { - GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1000U, 1024U), TensorShape(1000U, 1U), TensorShape(1000U, 1U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, - GEMMDataObject{ TensorShape(1152U, 2704U), TensorShape(256U, 1152U), TensorShape(256U, 2704U), TensorShape(256U, 2704U), 1.0f, 0.0f }, - } - { - } - - ~MatrixMultiplyDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ diff --git a/tests/validation_old/dataset/GenericDataset.h b/tests/validation_old/dataset/GenericDataset.h deleted file mode 100644 index d2c9f2db34..0000000000 --- a/tests/validation_old/dataset/GenericDataset.h +++ /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. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing multiple objects T. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different configurations. - */ -template -class GenericDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = T; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _data.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const T *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _data.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - GenericDataset(Ts... objs) - : _data{ { objs... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~GenericDataset() = default; - -private: - std::array _data; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ */ diff --git a/tests/validation_old/dataset/ImageDatasets.h b/tests/validation_old/dataset/ImageDatasets.h deleted file mode 100644 index 7fcd067e1b..0000000000 --- a/tests/validation_old/dataset/ImageDatasets.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_IMAGE_DATASETS_H__ -#define __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing image names. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different images. - */ -template -class ImageDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = const std::string; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _images.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const std::string *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _images.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - ImageDataset(Ts... images) - : _images{ { images... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~ImageDataset() = default; - -private: - std::array _images; -}; - -/** Data set containing names of small images. */ -class SmallImages final : public ImageDataset<2> -{ -public: - SmallImages() - : ImageDataset("128x128.ppm", "640x480.ppm") - { - } -}; - -/** Data set containing names of large images. */ -class LargeImages final : public ImageDataset<3> -{ -public: - LargeImages() -#ifdef INTERNAL_ONLY - : ImageDataset("1280x720.ppm", "1920x1080.ppm", "4160x3120.ppm") - // The 4k image is too large to distribute -#else /* INTERNAL_ONLY */ - : ImageDataset("1280x720.ppm", "1920x1080.ppm") -#endif /* INTERNAL_ONLY */ - { - } -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/InterpolationPolicyDataset.h b/tests/validation_old/dataset/InterpolationPolicyDataset.h deleted file mode 100644 index 64cc9bf239..0000000000 --- a/tests/validation_old/dataset/InterpolationPolicyDataset.h +++ /dev/null @@ -1,80 +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_INTERPOLATION_POLICY_DATASET_H__ -#define __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible interpolation policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all interpolation policies. - */ -class InterpolationPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = InterpolationPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const InterpolationPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR, InterpolationPolicy::AREA } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ */ diff --git a/tests/validation_old/dataset/MatrixPatternDataset.h b/tests/validation_old/dataset/MatrixPatternDataset.h deleted file mode 100644 index 5100ae0eaf..0000000000 --- a/tests/validation_old/dataset/MatrixPatternDataset.h +++ /dev/null @@ -1,82 +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_DATASETS_TEST_MATRIX_PATTERN_DATASET_H__ -#define __ARM_COMPUTE_DATASETS_TEST_MATRIX_PATTERN_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible border modes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class MatrixPatterns -{ -public: - /** Type of the samples in the data set. */ - using sample = MatrixPattern; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _patterns.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const MatrixPattern *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _patterns.data(); - } - -private: - std::array _patterns{ { MatrixPattern::BOX, MatrixPattern::CROSS, MatrixPattern::DISK, MatrixPattern::OTHER } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_DATASETS_TEST_MATRIX_PATTERN_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h b/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h deleted file mode 100644 index 5beeb141b1..0000000000 --- a/tests/validation_old/dataset/NonLinearFilterFunctionDataset.h +++ /dev/null @@ -1,82 +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_DATASETS_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ -#define __ARM_COMPUTE_DATASETS_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -#include - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible non linear filter function. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all border modes. - */ -class NonLinearFilterFunctions -{ -public: - /** Type of the samples in the data set. */ - using sample = NonLinearFilterFunction; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _functions.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const NonLinearFilterFunction *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _functions.data(); - } - -private: - std::array _functions{ { NonLinearFilterFunction::MAX, NonLinearFilterFunction::MEDIAN, NonLinearFilterFunction::MIN } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_DATASETS_TEST_NON_LINEAR_FILTER_FUNCTION_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NormalizationLayerDataset.h b/tests/validation_old/dataset/NormalizationLayerDataset.h deleted file mode 100644 index 489d1e0af2..0000000000 --- a/tests/validation_old/dataset/NormalizationLayerDataset.h +++ /dev/null @@ -1,99 +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_DATASET_NORMALIZATION_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class NormalizationLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "NormalizationLayer"; - ss << "_I" << shape; - ss << "_F_" << info.type(); - ss << "_S_" << info.norm_size(); - return ss.str(); - } - -public: - TensorShape shape; - NormalizationLayerInfo info; -}; - -template -using NormalizationLayerDataset = GenericDataset; - -class GoogLeNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> -{ -public: - GoogLeNetNormalizationLayerDataset() - : GenericDataset - { - // conv2/norm2 - NormalizationLayerDataObject{ TensorShape(56U, 56U, 192U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - // pool1/norm1 - NormalizationLayerDataObject{ TensorShape(56U, 56U, 64U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) } - } - { - } - - ~GoogLeNetNormalizationLayerDataset() = default; -}; - -class AlexNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> -{ -public: - AlexNetNormalizationLayerDataset() - : GenericDataset - { - NormalizationLayerDataObject{ TensorShape(55U, 55U, 96U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - NormalizationLayerDataObject{ TensorShape(27U, 27U, 256U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, - } - { - } - - ~AlexNetNormalizationLayerDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ */ diff --git a/tests/validation_old/dataset/NormalizationTypeDataset.h b/tests/validation_old/dataset/NormalizationTypeDataset.h deleted file mode 100644 index 2a89dbea30..0000000000 --- a/tests/validation_old/dataset/NormalizationTypeDataset.h +++ /dev/null @@ -1,80 +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_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible normalization types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all normalization types. - */ -class NormalizationTypes -{ -public: - /** Type of the samples in the data set. */ - using sample = NormType; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _types.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const NormType *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _types.data(); - } - -private: - const std::array _types{ { NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ */ diff --git a/tests/validation_old/dataset/PoolingLayerDataset.h b/tests/validation_old/dataset/PoolingLayerDataset.h deleted file mode 100644 index a4e570c35e..0000000000 --- a/tests/validation_old/dataset/PoolingLayerDataset.h +++ /dev/null @@ -1,138 +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_DATASET_POOLING_LAYER_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class PoolingLayerDataObject -{ -public: - operator std::string() const - { - std::stringstream ss; - ss << "PoolingLayer"; - ss << "_I" << src_shape; - ss << "_S_" << info.pool_size(); - ss << "_F_" << info.pool_type(); - ss << "_PS" << info.pad_stride_info(); - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &s, const PoolingLayerDataObject &obj) - { - s << static_cast(obj); - return s; - } - -public: - TensorShape src_shape; - TensorShape dst_shape; - PoolingLayerInfo info; -}; - -template -using PoolingLayerDataset = GenericDataset; - -class AlexNetPoolingLayerDataset final : public PoolingLayerDataset<3> -{ -public: - AlexNetPoolingLayerDataset() - : GenericDataset - { - PoolingLayerDataObject{ TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, - } - { - } - - ~AlexNetPoolingLayerDataset() = default; -}; - -class LeNet5PoolingLayerDataset final : public PoolingLayerDataset<2> -{ -public: - LeNet5PoolingLayerDataset() - : GenericDataset - { - PoolingLayerDataObject{ TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, - PoolingLayerDataObject{ TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, - } - { - } - - ~LeNet5PoolingLayerDataset() = default; -}; - -class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset<10> -{ -public: - GoogLeNetPoolingLayerDataset() - : GenericDataset - { - // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 - // pool1/3x3_s2 - PoolingLayerDataObject{ TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // pool2/3x3_s2 - PoolingLayerDataObject{ TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_3a/pool - PoolingLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_3b/pool - PoolingLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // pool3/3x3_s2 - PoolingLayerDataObject{ TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_4a/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_4b/pool, inception_4c/pool, inception_4d/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // inception_4e/pool - PoolingLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - // pool4/3x3_s2 - PoolingLayerDataObject{ TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, - // inception_5a/pool, inception_5b/pool - PoolingLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, - } - { - } - - ~GoogLeNetPoolingLayerDataset() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ diff --git a/tests/validation_old/dataset/PoolingTypesDataset.h b/tests/validation_old/dataset/PoolingTypesDataset.h deleted file mode 100644 index a826df35ce..0000000000 --- a/tests/validation_old/dataset/PoolingTypesDataset.h +++ /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. - */ -#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ - -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible pooling types. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on all pooling types. - */ -class PoolingTypes final : public GenericDataset -{ -public: - PoolingTypes() - : GenericDataset{ PoolingType::MAX, PoolingType::AVG } - { - } - - ~PoolingTypes() = default; -}; -} // namespace test -} // namespace arm_compute -#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_TYPE_DATASET_H__ diff --git a/tests/validation_old/dataset/RoundingPolicyDataset.h b/tests/validation_old/dataset/RoundingPolicyDataset.h deleted file mode 100644 index af946b41bd..0000000000 --- a/tests/validation_old/dataset/RoundingPolicyDataset.h +++ /dev/null @@ -1,82 +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_ROUNDING_POLICY_DATASETS_H__ -#define __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ - -#include "arm_compute/core/Types.h" - -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Data set containing all possible rounding policies. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different rounding policies. - */ -class RoundingPolicies -{ -public: - /** Type of the samples in the data set. */ - using sample = RoundingPolicy; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _policies.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const RoundingPolicy *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _policies.data(); - } - -private: - std::array _policies{ { RoundingPolicy::TO_ZERO, RoundingPolicy::TO_NEAREST_UP, RoundingPolicy::TO_NEAREST_EVEN } }; -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ShapeDatasets.h b/tests/validation_old/dataset/ShapeDatasets.h deleted file mode 100644 index 3c986ab7ae..0000000000 --- a/tests/validation_old/dataset/ShapeDatasets.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_SHAPE_DATASETS_H__ -#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ - -#include "arm_compute/core/TensorShape.h" - -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -/** Abstract data set containing tensor shapes. - * - * Can be used as input for Boost data test cases to automatically run a test - * case on different tensor shapes. - */ -template -class ShapeDataset -{ -public: - /** Type of the samples in the data set. */ - using sample = TensorShape; - - /** Dimensionality of the data set. */ - enum - { - arity = 1 - }; - - /** Number of samples in the data set. */ -#ifdef BOOST - boost::unit_test::data::size_t size() const -#else /* BOOST */ - unsigned int size() const -#endif /* BOOST */ - { - return _shapes.size(); - } - - /** Type of the iterator used to step through all samples in the data set. - * Needs to support operator*() and operator++() which a pointer does. - */ - using iterator = const TensorShape *; - - /** Iterator to the first sample in the data set. */ - iterator begin() const - { - return _shapes.data(); - } - -protected: - /** Protected constructor to make the class abstract. */ - template - ShapeDataset(Ts... shapes) - : _shapes{ { shapes... } } - { - } - - /** Protected destructor to prevent deletion of derived class through a - * pointer to the base class. - */ - ~ShapeDataset() = default; - -private: - std::array _shapes; -}; - -/** Data set containing one 1D tensor shape. */ -class Small1DShape final : public ShapeDataset<1> -{ -public: - Small1DShape() - : ShapeDataset(TensorShape(256U)) - { - } -}; - -/** Data set containing two small 2D tensor shapes. */ -class Small2DShapes final : public ShapeDataset<2> -{ -public: - Small2DShapes() - : ShapeDataset(TensorShape(17U, 17U), - TensorShape(640U, 480U)) - { - } -}; - -/** Data set containing small tensor shapes. */ -class SmallShapes final : public ShapeDataset<3> -{ -public: - SmallShapes() - : ShapeDataset(TensorShape(7U, 7U), - TensorShape(27U, 13U, 2U), - TensorShape(128U, 64U, 1U, 3U)) - { - } -}; - -/** Data set containing large tensor shapes. */ -class LargeShapes final : public ShapeDataset<3> -{ -public: - LargeShapes() - : ShapeDataset(TensorShape(1920U, 1080U), - TensorShape(1245U, 652U, 1U, 3U), - TensorShape(4160U, 3120U)) - { - } -}; - -/** Data set containing two 2D large tensor shapes. */ -class Large2DShapes final : public ShapeDataset<2> -{ -public: - Large2DShapes() - : ShapeDataset(TensorShape(1920U, 1080U), - TensorShape(4160U, 3120U)) - { - } -}; -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ diff --git a/tests/validation_old/dataset/ThresholdDataset.h b/tests/validation_old/dataset/ThresholdDataset.h deleted file mode 100644 index 789ffac14a..0000000000 --- a/tests/validation_old/dataset/ThresholdDataset.h +++ /dev/null @@ -1,95 +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_DATASET_THRESHOLD_DATASET_H__ -#define __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "tests/validation_old/dataset/GenericDataset.h" - -#include -#include - -#include -#include - -#ifdef BOOST -#include "tests/validation_old/boost_wrapper.h" -#endif /* BOOST */ - -namespace arm_compute -{ -namespace test -{ -class ThresholdDataObject -{ -public: - uint8_t threshold; - uint8_t false_value; - uint8_t true_value; - ThresholdType type; - uint8_t upper; - - operator std::string() const - { - std::stringstream ss; - ss << "Threshold"; - ss << "_threshold_value" << threshold; - ss << "_false_value" << std::boolalpha << false_value; - ss << "_true_value" << std::boolalpha << true_value; - ss << "_type"; - ss << ((type == ThresholdType::BINARY) ? "binary" : "range"); - ss << "_upper" << upper; - return ss.str(); - } - - friend std::ostream &operator<<(std::ostream &os, const ThresholdDataObject &obj) - { - os << static_cast(obj); - return os; - } -}; - -class ThresholdDataset : public GenericDataset -{ -public: - ThresholdDataset() - : GenericDataset - { - ThresholdDataObject{ 10U, 25U, 3U, ThresholdType::BINARY, 0U }, - ThresholdDataObject{ 20U, 1U, 0U, ThresholdType::BINARY, 0U }, - ThresholdDataObject{ 30U, 1U, 0U, ThresholdType::RANGE, 100U }, - ThresholdDataObject{ 100U, 1U, 0U, ThresholdType::RANGE, 200U }, - } - { - } - - ~ThresholdDataset() = default; -}; - -} // namespace test -} // namespace arm_compute -#endif /* __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ */ diff --git a/tests/validation_old/half.h b/tests/validation_old/half.h deleted file mode 100644 index d8aa341068..0000000000 --- a/tests/validation_old/half.h +++ /dev/null @@ -1,37 +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__ */ diff --git a/tests/validation_old/main.cpp b/tests/validation_old/main.cpp deleted file mode 100644 index 9f15c3a7bc..0000000000 --- a/tests/validation_old/main.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. - */ -#define BOOST_TEST_ALTERNATIVE_INIT_API - -#include "Utils.h" -#include "ValidationProgramOptions.h" -#include "ValidationUserConfiguration.h" -#include "support/ToolchainSupport.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" - -#include "arm_compute/runtime/Scheduler.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include -#include -#include - -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace arm_compute -{ -namespace test -{ -ValidationUserConfiguration user_config; -std::unique_ptr library; -} // namespace test -} // namespace arm_compute - -struct GlobalFixture -{ - GlobalFixture() - { - library = arm_compute::support::cpp14::make_unique(user_config.path.get(), user_config.seed); - std::cout << "Seed: " << library->seed() << "\n"; - } -}; - -BOOST_GLOBAL_FIXTURE(GlobalFixture); - -bool init_unit_test() -{ - boost::unit_test::framework::master_test_suite().p_name.value = "Compute Library Validation Tests"; - - ValidationProgramOptions options; - - int &argc = boost::unit_test::framework::master_test_suite().argc; - char **argv = boost::unit_test::framework::master_test_suite().argv; - - try - { - options.parse_commandline(argc, argv); - - if(options.wants_help()) - { - std::cout << "Usage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - return false; - } - - user_config = ValidationUserConfiguration(options); - } - catch(const boost::program_options::required_option &err) - { - std::cerr << "Error: " << err.what() << "\n"; - std::cout << "\nUsage: " << argv[0] << " [options] PATH\n"; - std::cout << options.get_help() << "\n"; - return false; - } - - std::cout << "Using " << user_config.threads << " CPU " << (user_config.threads == 1 ? "thread" : "threads") << "\n"; - arm_compute::Scheduler::get().set_num_threads(user_config.threads); - return true; -} -- cgit v1.2.1