From a09de0c8b2ed0f1481502d3b023375609362d9e3 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Fri, 1 Sep 2017 20:41:12 +0100 Subject: COMPMID-415: Rename and move tests The boost validation is now "standalone" in validation_old and builds as arm_compute_validation_old. The new validation builds now as arm_compute_validation. Change-Id: Ib93ba848a25680ac60afb92b461d574a0757150d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86187 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- .../fixtures/ActivationLayerFixture.h | 157 ------------- tests/validation_new/fixtures/BitwiseAndFixture.h | 113 ---------- tests/validation_new/fixtures/BitwiseNotFixture.h | 106 --------- tests/validation_new/fixtures/BitwiseOrFixture.h | 113 ---------- tests/validation_new/fixtures/BitwiseXorFixture.h | 113 ---------- .../fixtures/ConvolutionLayerFixture.h | 152 ------------- .../fixtures/DepthConcatenateLayerFixture.h | 177 --------------- .../fixtures/DepthwiseConvolutionFixture.h | 120 ---------- .../DepthwiseSeparableConvolutionLayerFixture.h | 139 ------------ .../fixtures/DequantizationLayerFixture.h | 147 ------------ .../fixtures/DirectConvolutionLayerFixture.h | 86 ------- tests/validation_new/fixtures/FloorFixture.h | 107 --------- .../fixtures/FullyConnectedLayerFixture.h | 250 --------------------- tests/validation_new/fixtures/GEMMFixture.h | 152 ------------- tests/validation_new/fixtures/L2NormalizeFixture.h | 107 --------- tests/validation_new/fixtures/MeanStdDevFixture.h | 102 --------- .../fixtures/NormalizationLayerFixture.h | 133 ----------- .../validation_new/fixtures/PoolingLayerFixture.h | 134 ----------- .../fixtures/QuantizationLayerFixture.h | 120 ---------- .../fixtures/ReductionOperationFixture.h | 116 ---------- tests/validation_new/fixtures/ScaleFixture.h | 127 ----------- .../validation_new/fixtures/SoftmaxLayerFixture.h | 133 ----------- 22 files changed, 2904 deletions(-) delete mode 100644 tests/validation_new/fixtures/ActivationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseAndFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseNotFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseOrFixture.h delete mode 100644 tests/validation_new/fixtures/BitwiseXorFixture.h delete mode 100644 tests/validation_new/fixtures/ConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthConcatenateLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseConvolutionFixture.h delete mode 100644 tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DequantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/DirectConvolutionLayerFixture.h delete mode 100644 tests/validation_new/fixtures/FloorFixture.h delete mode 100644 tests/validation_new/fixtures/FullyConnectedLayerFixture.h delete mode 100644 tests/validation_new/fixtures/GEMMFixture.h delete mode 100644 tests/validation_new/fixtures/L2NormalizeFixture.h delete mode 100644 tests/validation_new/fixtures/MeanStdDevFixture.h delete mode 100644 tests/validation_new/fixtures/NormalizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/PoolingLayerFixture.h delete mode 100644 tests/validation_new/fixtures/QuantizationLayerFixture.h delete mode 100644 tests/validation_new/fixtures/ReductionOperationFixture.h delete mode 100644 tests/validation_new/fixtures/ScaleFixture.h delete mode 100644 tests/validation_new/fixtures/SoftmaxLayerFixture.h (limited to 'tests/validation_new/fixtures') diff --git a/tests/validation_new/fixtures/ActivationLayerFixture.h b/tests/validation_new/fixtures/ActivationLayerFixture.h deleted file mode 100644 index bf0e7ba6ea..0000000000 --- a/tests/validation_new/fixtures/ActivationLayerFixture.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ActivationLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ActivationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - _function = function; - - ActivationLayerInfo info(function, alpha_beta, alpha_beta); - - _target = compute_target(shape, in_place, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(is_data_type_float(_data_type)) - { - float min_bound = 0; - float max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type); - std::uniform_real_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - else - { - int min_bound = 0; - int max_bound = 0; - std::tie(min_bound, max_bound) = get_activation_layer_test_bounds(_function, _data_type, _fractional_bits); - std::uniform_int_distribution<> distribution(min_bound, max_bound); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, bool in_place, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType act_layer; - - TensorType *dst_ptr = in_place ? &src : &dst; - - act_layer.configure(&src, dst_ptr, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - if(!in_place) - { - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - act_layer.run(); - - if(in_place) - { - return src; - } - else - { - return dst; - } - } - - SimpleTensor compute_reference(const TensorShape &shape, ActivationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::activation_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; - ActivationLayerInfo::ActivationFunction _function{}; -}; - -template -class ActivationValidationFixture : public ActivationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, bool in_place, ActivationLayerInfo::ActivationFunction function, float alpha_beta, DataType data_type) - { - ActivationValidationFixedPointFixture::setup(shape, in_place, function, alpha_beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ACTIVATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseAndFixture.h b/tests/validation_new/fixtures/BitwiseAndFixture.h deleted file mode 100644 index 1769ecdb1f..0000000000 --- a/tests/validation_new/fixtures/BitwiseAndFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseAnd.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseAndValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_and; - - bitwise_and.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_and.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_and(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_AND_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseNotFixture.h b/tests/validation_new/fixtures/BitwiseNotFixture.h deleted file mode 100644 index 5954c8639e..0000000000 --- a/tests/validation_new/fixtures/BitwiseNotFixture.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseNot.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseNotValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_not; - - bitwise_not.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - bitwise_not.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::bitwise_not(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_NOT_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseOrFixture.h b/tests/validation_new/fixtures/BitwiseOrFixture.h deleted file mode 100644 index b39b46e813..0000000000 --- a/tests/validation_new/fixtures/BitwiseOrFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseOr.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseOrValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_or; - - bitwise_or.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_or.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_or(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_OR_FIXTURE */ diff --git a/tests/validation_new/fixtures/BitwiseXorFixture.h b/tests/validation_new/fixtures/BitwiseXorFixture.h deleted file mode 100644 index 1dfbf1f784..0000000000 --- a/tests/validation_new/fixtures/BitwiseXorFixture.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE -#define ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/BitwiseXor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class BitwiseXorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src1 = create_tensor(shape, data_type); - TensorType src2 = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType bitwise_xor; - - bitwise_xor.configure(&src1, &src2, &dst); - - ARM_COMPUTE_EXPECT(src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src1.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!src2.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src1), 0); - fill(AccessorType(src2), 1); - - // Compute function - bitwise_xor.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src1{ shape, data_type }; - SimpleTensor src2{ shape, data_type }; - - // Fill reference - fill(src1, 0); - fill(src2, 1); - - return reference::bitwise_xor(src1, src2); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_BITWISE_XOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/ConvolutionLayerFixture.h b/tests/validation_new/fixtures/ConvolutionLayerFixture.h deleted file mode 100644 index 25a53d0c1d..0000000000 --- a/tests/validation_new/fixtures/ConvolutionLayerFixture.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ConvolutionValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType conv; - conv.configure(&src, &weights, &bias, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - fill(AccessorType(bias), 2); - - // Compute NEConvolutionLayer function - conv.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::convolution_layer(src, weights, bias, output_shape, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class ConvolutionValidationFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, DataType data_type) - { - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h b/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h deleted file mode 100644 index 601758f80e..0000000000 --- a/tests/validation_new/fixtures/DepthConcatenateLayerFixture.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthConcatenateLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -class ITensor; -class Tensor; -class ICLTensor; -class CLTensor; - -namespace test -{ -namespace validation -{ -template -class DepthConcatenateValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Create input shapes - std::mt19937 gen(library->seed()); - std::uniform_int_distribution<> num_dis(2, 6); - const int num_tensors = num_dis(gen); - - std::vector shapes(num_tensors, shape); - std::uniform_int_distribution<> depth_dis(1, 7); - std::bernoulli_distribution mutate_dis(0.25f); - std::uniform_real_distribution<> change_dis(-0.25f, 0.f); - - // Generate more shapes based on the input - for(auto &s : shapes) - { - // Set the depth of the tensor - s.set(2, depth_dis(gen)); - - // Randomly change the first dimension - if(mutate_dis(gen)) - { - // Decrease the dimension by a small percentage. Don't increase - // as that could make tensor too large. Also the change must be - // an even number. Otherwise out depth concatenate fails. - s.set(0, s[0] + 2 * static_cast(s[0] * change_dis(gen))); - } - - // Repeat the same as above for the second dimension - if(mutate_dis(gen)) - { - s.set(1, s[1] + 2 * static_cast(s[1] * change_dis(gen))); - } - } - - _target = compute_target(shapes, data_type); - _reference = compute_reference(shapes, data_type); - } - -protected: - template - void fill(U &&tensor, int i) - { - library->fill_tensor_uniform(tensor, i); - } - - TensorType compute_target(std::vector shapes, DataType data_type) - { - using ITensorType = typename std::conditional::value, ITensor, ICLTensor>::type; - - std::vector srcs; - std::vector src_ptrs; - - // Create tensors - srcs.reserve(shapes.size()); - - for(const auto &shape : shapes) - { - srcs.emplace_back(create_tensor(shape, data_type, 1, _fractional_bits)); - src_ptrs.emplace_back(&srcs.back()); - } - - TensorShape dst_shape = calculate_depth_concatenate_shape(shapes); - TensorType dst = create_tensor(dst_shape, data_type, 1, _fractional_bits); - - // Create and configure function - FunctionType depth_concat; - depth_concat.configure(src_ptrs, &dst); - - for(auto &src : srcs) - { - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - for(auto &src : srcs) - { - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - } - - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - int i = 0; - for(auto &src : srcs) - { - fill(AccessorType(src), i++); - } - - // Compute function - depth_concat.run(); - - return dst; - } - - SimpleTensor compute_reference(std::vector shapes, DataType data_type) - { - std::vector> srcs; - - // Create and fill tensors - int i = 0; - for(const auto &shape : shapes) - { - srcs.emplace_back(shape, data_type, 1, _fractional_bits); - fill(srcs.back(), i++); - } - - return reference::depthconcatenate_layer(srcs); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - int _fractional_bits{ 1 }; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHCONCATENATE_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h b/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h deleted file mode 100644 index b745c7e53c..0000000000 --- a/tests/validation_new/fixtures/DepthwiseConvolutionFixture.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseConvolution.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape weights_shape, TensorShape out_shape, PadStrideInfo pad_stride_info) - { - _target = compute_target(in_shape, weights_shape, out_shape, pad_stride_info); - _reference = compute_reference(in_shape, weights_shape, out_shape, pad_stride_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &output_shape, PadStrideInfo &pad_stride_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType weights = create_tensor(weights_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Convolution configure function - CLDepthwiseConvolution depthwise_convolution; - depthwise_convolution.configure(&src, &dst, &weights, pad_stride_info); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(weights), 1); - - // Compute function - depthwise_convolution.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &weights_shape, const TensorShape &out_shape, const PadStrideInfo &pad_stride_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor weights(weights_shape, DataType::F32); - - fill(src, 0); - fill(weights, 1); - - return reference::depthwise_convolution(src, weights, out_shape, pad_stride_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_CONVOLUTION_FIXTURE */ diff --git a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h deleted file mode 100644 index c2578a9ce0..0000000000 --- a/tests/validation_new/fixtures/DepthwiseSeparableConvolutionLayerFixture.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DepthwiseSeparableConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DepthwiseSeparableConvolutionValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape in_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape output_shape, - PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info) - { - _target = compute_target(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - _reference = compute_reference(in_shape, depthwise_weights_shape, depthwise_out_shape, pointwise_weights_shape, biases_shape, output_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, - const TensorShape &output_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, DataType::F32); - TensorType depthwise_weights = create_tensor(depthwise_weights_shape, DataType::F32); - TensorType depthwise_out = create_tensor(depthwise_out_shape, DataType::F32); - TensorType pointwise_weights = create_tensor(pointwise_weights_shape, DataType::F32); - TensorType biases = create_tensor(biases_shape, DataType::F32); - TensorType dst = create_tensor(output_shape, DataType::F32); - - // Create Depthwise Separable Convolution Layer configure function - CLDepthwiseSeparableConvolutionLayer depthwise_separable_convolution_layer; - depthwise_separable_convolution_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); - - // Allocate tensors - src.allocator()->allocate(); - depthwise_weights.allocator()->allocate(); - depthwise_out.allocator()->allocate(); - pointwise_weights.allocator()->allocate(); - biases.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!depthwise_out.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!pointwise_weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!biases.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(depthwise_weights), 1); - fill(AccessorType(pointwise_weights), 2); - fill(AccessorType(biases), 3); - - // Compute function - depthwise_separable_convolution_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &in_shape, const TensorShape &depthwise_weights_shape, const TensorShape &depthwise_out_shape, const TensorShape &pointwise_weights_shape, - const TensorShape &biases_shape, const TensorShape &dst_shape, const PadStrideInfo &pad_stride_depthwise_info, const PadStrideInfo &pad_stride_pointwise_info) - { - SimpleTensor src(in_shape, DataType::F32); - SimpleTensor depthwise_weights(depthwise_weights_shape, DataType::F32); - SimpleTensor pointwise_weights(pointwise_weights_shape, DataType::F32); - SimpleTensor biases(biases_shape, DataType::F32); - - fill(src, 0); - fill(depthwise_weights, 1); - fill(pointwise_weights, 2); - fill(biases, 3); - - return reference::depthwise_separable_convolution_layer(src, depthwise_weights, depthwise_out_shape, pointwise_weights, biases, dst_shape, pad_stride_depthwise_info, pad_stride_pointwise_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEPTHWISE_SEPARABLE_CONVOLUTION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DequantizationLayerFixture.h b/tests/validation_new/fixtures/DequantizationLayerFixture.h deleted file mode 100644 index 35c536d6a0..0000000000 --- a/tests/validation_new/fixtures/DequantizationLayerFixture.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/DequantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DequantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - // Initialize random min and max values - rand_min_max(&_min, &_max); - - _target = compute_target(shape, data_type, _min, _max); - _reference = compute_reference(shape, data_type, _min, _max); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::F32); - - // Create and configure function - FunctionType dequantization_layer; - dequantization_layer.configure(&src, &dst, &min, &max); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - dequantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, float min, float max) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::dequantization_layer(src, min, max); - } - - /** Generate random constant values to be used as min and max for dequantization. - */ - void rand_min_max(float *min, float *max) - { - std::mt19937 gen(library->seed()); - std::uniform_real_distribution distribution(-10000.0, 10000.0); - - const float n1 = distribution(gen); - const float n2 = distribution(gen); - - if(n1 < n2) - { - *min = n1; - *max = n2; - } - else - { - *min = n2; - *max = n1; - } - } - - TensorType _target{}; - SimpleTensor _reference{}; - float _min = 0.f; - float _max = 0.f; -}; - -template -class DequantizationValidationFixture : public DequantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - DequantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_DEQUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h b/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h deleted file mode 100644 index 0d138b47d9..0000000000 --- a/tests/validation_new/fixtures/DirectConvolutionLayerFixture.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ConvolutionLayer.h" -#include "tests/validation_new/Helpers.h" -#include "tests/validation_new/fixtures/ConvolutionLayerFixture.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class DirectConvolutionValidationFixedPointFixture : public ConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type, int fractional_bits) - { - const TensorShape weights_shape(kernel_size, kernel_size, input_shape.z(), num_kernels); - const TensorShape bias_shape(num_kernels); - const PadStrideInfo info(stride_x, stride_y, pad_x, pad_y, DimensionRoundingType::FLOOR); - const TensorShape output_shape = get_output_shape(input_shape, weights_shape, info); - - ConvolutionValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, info, data_type, fractional_bits); - } - -private: - TensorShape get_output_shape(TensorShape in_shape, TensorShape kernel_shape, const PadStrideInfo &info) - { - TensorShape out_shape(in_shape); - const std::pair scaled_dims = scaled_dimensions(in_shape.x(), - in_shape.y(), - kernel_shape.x(), - kernel_shape.y(), - info); - out_shape.set(0, scaled_dims.first); - out_shape.set(1, scaled_dims.second); - out_shape.set(2, kernel_shape[3]); - return out_shape; - } -}; - -template -class DirectConvolutionValidationFixture : public DirectConvolutionValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, int stride_x, int stride_y, int pad_x, int pad_y, unsigned int kernel_size, unsigned int num_kernels, DataType data_type) - { - DirectConvolutionValidationFixedPointFixture::setup(input_shape, stride_x, stride_y, pad_x, pad_y, kernel_size, num_kernels, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation_new/fixtures/FloorFixture.h b/tests/validation_new/fixtures/FloorFixture.h deleted file mode 100644 index ab4c5c7e1e..0000000000 --- a/tests/validation_new/fixtures/FloorFixture.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FLOOR_FIXTURE -#define ARM_COMPUTE_TEST_FLOOR_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Floor.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class FloorValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType floor_func; - floor_func.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - floor_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::floor_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FLOOR_FIXTURE */ diff --git a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h b/tests/validation_new/fixtures/FullyConnectedLayerFixture.h deleted file mode 100644 index 0953b0b67e..0000000000 --- a/tests/validation_new/fixtures/FullyConnectedLayerFixture.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/Utils.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/RawTensor.h" -#include "tests/validation_new/CPP/FullyConnectedLayer.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -RawTensor transpose(const RawTensor &src, int interleave = 1) -{ - // Create reference - TensorShape dst_shape(src.shape()); - dst_shape.set(0, src.shape().y() * interleave); - dst_shape.set(1, std::ceil(src.shape().x() / static_cast(interleave))); - - RawTensor dst{ dst_shape, src.data_type() }; - - // Compute reference - uint8_t *out_ptr = dst.data(); - - for(int i = 0; i < dst.num_elements(); i += interleave) - { - Coordinates coord = index2coord(dst.shape(), i); - size_t coord_x = coord.x(); - coord.set(0, coord.y() * interleave); - coord.set(1, coord_x / interleave); - - const int num_elements = std::min(interleave, src.shape().x() - coord.x()); - - std::copy_n(static_cast(src(coord)), num_elements * src.element_size(), out_ptr); - - out_ptr += interleave * dst.element_size(); - } - - return dst; -} -} // namespace - -template -class FullyConnectedLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type, int fractional_bits) - { - ARM_COMPUTE_UNUSED(weights_shape); - ARM_COMPUTE_UNUSED(bias_shape); - - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, reshape_weights, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - if(is_data_type_float(_data_type)) - { - std::uniform_real_distribution<> distribution(0.5f, 1.f); - library->fill(tensor, distribution, i); - } - else - { - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position) - { - TensorShape reshaped_weights_shape(weights_shape); - - // Test actions depending on the target settings - // - // | reshape | !reshape - // -----------+-----------+--------------------------- - // transpose | | *** - // -----------+-----------+--------------------------- - // !transpose | transpose | transpose & - // | | transpose1xW (if required) - // - // ***: That combination is invalid. But we can ignore the transpose flag and handle all !reshape the same - if(!reshape_weights || !transpose_weights) - { - const size_t shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y()); - reshaped_weights_shape.set(1, shape_x); - - // Weights have to be passed reshaped - // Transpose 1xW for batched version - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - const int transpose_width = 16 / data_size_from_type(data_type); - const float shape_x = reshaped_weights_shape.x(); - reshaped_weights_shape.set(0, reshaped_weights_shape.y() * transpose_width); - reshaped_weights_shape.set(1, static_cast(std::ceil(shape_x / transpose_width))); - } - } - - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, fixed_point_position); - TensorType weights = create_tensor(reshaped_weights_shape, data_type, 1, fixed_point_position); - TensorType bias = create_tensor(bias_shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function. - FunctionType fc; - fc.configure(&src, &weights, &bias, &dst, transpose_weights, !reshape_weights); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - weights.allocator()->allocate(); - bias.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src), 0); - fill(AccessorType(bias), 2); - - if(!reshape_weights || !transpose_weights) - { - TensorShape tmp_shape(weights_shape); - RawTensor tmp(tmp_shape, data_type, 1, fixed_point_position); - - // Fill with original shape - fill(tmp, 1); - - // Transpose elementwise - tmp = transpose(tmp); - - // Reshape weights for batched runs - if(!reshape_weights && output_shape.y() > 1 && run_interleave) - { - // Transpose with interleave - const int interleave_size = 16 / tmp.element_size(); - tmp = transpose(tmp, interleave_size); - } - - AccessorType weights_accessor(weights); - - for(int i = 0; i < tmp.num_elements(); ++i) - { - Coordinates coord = index2coord(tmp.shape(), i); - std::copy_n(static_cast(tmp(coord)), - tmp.element_size(), - static_cast(weights_accessor(coord))); - } - } - else - { - fill(AccessorType(weights), 1); - } - - // Compute NEFullyConnectedLayer function - fc.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, bool transpose_weights, - bool reshape_weights, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, fixed_point_position }; - SimpleTensor weights{ weights_shape, data_type, 1, fixed_point_position }; - SimpleTensor bias{ bias_shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::fully_connected_layer(src, weights, bias, output_shape); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class FullyConnectedLayerValidationFixture : public FullyConnectedLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, bool transpose_weights, bool reshape_weights, DataType data_type) - { - FullyConnectedLayerValidationFixedPointFixture::setup(input_shape, weights_shape, bias_shape, output_shape, transpose_weights, - reshape_weights, data_type, - 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_FULLY_CONNECTED_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/GEMMFixture.h b/tests/validation_new/fixtures/GEMMFixture.h deleted file mode 100644 index a6ab518d74..0000000000 --- a/tests/validation_new/fixtures/GEMMFixture.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_GEMM_FIXTURE -#define ARM_COMPUTE_TEST_GEMM_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/GEMM.h" -#include "tests/validation_new/Helpers.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class GEMMValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - _data_type = data_type; - - _target = compute_target(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - _reference = compute_reference(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor, int i) - { - switch(tensor.data_type()) - { - case DataType::F16: - case DataType::F32: - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - break; - } - default: - library->fill_tensor_uniform(tensor, i); - } - } - - TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create tensors - TensorType a = create_tensor(shape_a, data_type, 1, fixed_point_position); - TensorType b = create_tensor(shape_b, data_type, 1, fixed_point_position); - TensorType c = create_tensor(shape_c, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(output_shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType gemm; - gemm.configure(&a, &b, &c, &dst, alpha, beta); - - ARM_COMPUTE_EXPECT(a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - a.allocator()->allocate(); - b.allocator()->allocate(); - c.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!a.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!b.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(a), 0); - fill(AccessorType(b), 1); - fill(AccessorType(c), 2); - - // Compute GEMM function - gemm.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &output_shape, float alpha, float beta, - DataType data_type, int fixed_point_position) - { - // Create reference - SimpleTensor a{ shape_a, data_type, 1, fixed_point_position }; - SimpleTensor b{ shape_b, data_type, 1, fixed_point_position }; - SimpleTensor c{ shape_c, data_type, 1, fixed_point_position }; - - // Fill reference - fill(a, 0); - fill(b, 1); - fill(c, 2); - - return reference::gemm(a, b, c, alpha, beta); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; - DataType _data_type{}; -}; - -template -class GEMMValidationFixture : public GEMMValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape output_shape, float alpha, float beta, DataType data_type) - { - GEMMValidationFixedPointFixture::setup(shape_a, shape_b, shape_c, output_shape, alpha, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_GEMM_FIXTURE */ diff --git a/tests/validation_new/fixtures/L2NormalizeFixture.h b/tests/validation_new/fixtures/L2NormalizeFixture.h deleted file mode 100644 index 5102b93f51..0000000000 --- a/tests/validation_new/fixtures/L2NormalizeFixture.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE -#define ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/L2Normalize.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class L2NormalizeValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, float epsilon) - { - _target = compute_target(shape, data_type, axis, epsilon); - _reference = compute_reference(shape, data_type, axis, epsilon); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, data_type); - - // Create and configure function - FunctionType l2_norm_func; - l2_norm_func.configure(&src, &dst, axis, epsilon); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - l2_norm_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, unsigned int axis, float epsilon) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::l2_normalize(src, axis, epsilon); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_L2NORMALIZE_FIXTURE */ diff --git a/tests/validation_new/fixtures/MeanStdDevFixture.h b/tests/validation_new/fixtures/MeanStdDevFixture.h deleted file mode 100644 index 65622fca07..0000000000 --- a/tests/validation_new/fixtures/MeanStdDevFixture.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE -#define ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE - -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/Globals.h" -#include "tests/validation_new/CPP/MeanStdDev.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class MeanStdDevValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - std::pair compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - - // Create output variables - float mean = 0.0f; - float std_dev = 0.0f; - - // Create and configure function - FunctionType mean_std_dev; - mean_std_dev.configure(&src, &mean, &std_dev); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - mean_std_dev.run(); - - return std::make_pair(mean, std_dev); - } - - std::pair compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - // Compute reference - return reference::mean_and_standard_deviation(src); - } - - std::pair _target{}; - std::pair _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_MEAN_STD_DEV_FIXTURE */ diff --git a/tests/validation_new/fixtures/NormalizationLayerFixture.h b/tests/validation_new/fixtures/NormalizationLayerFixture.h deleted file mode 100644 index 044405473b..0000000000 --- a/tests/validation_new/fixtures/NormalizationLayerFixture.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/NormalizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class NormalizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - NormalizationLayerInfo info(norm_type, norm_size, 5, beta); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - library->fill_tensor_uniform(tensor, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType norm_layer; - norm_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - norm_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, NormalizationLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::normalization_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class NormalizationValidationFixture : public NormalizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, NormType norm_type, int norm_size, float beta, DataType data_type) - { - NormalizationValidationFixedPointFixture::setup(shape, norm_type, norm_size, beta, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_NORMALIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/PoolingLayerFixture.h b/tests/validation_new/fixtures/PoolingLayerFixture.h deleted file mode 100644 index c0c818f3a0..0000000000 --- a/tests/validation_new/fixtures/PoolingLayerFixture.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/PoolingLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class PoolingLayerValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - PoolingLayerInfo info(pool_type, pool_size, pad_stride_info); - - _target = compute_target(shape, info, data_type, fractional_bits); - _reference = compute_reference(shape, info, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1.f, 1.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst; - - // Create and configure function - FunctionType pool_layer; - pool_layer.configure(&src, &dst, info); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - pool_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, PoolingLayerInfo info, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::pooling_layer(src, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class PoolingLayerValidationFixture : public PoolingLayerValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, PoolingType pool_type, int pool_size, PadStrideInfo pad_stride_info, DataType data_type) - { - PoolingLayerValidationFixedPointFixture::setup(shape, pool_type, pool_size, pad_stride_info, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_POOLING_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/QuantizationLayerFixture.h b/tests/validation_new/fixtures/QuantizationLayerFixture.h deleted file mode 100644 index 469fd5f231..0000000000 --- a/tests/validation_new/fixtures/QuantizationLayerFixture.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/QuantizationLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class QuantizationValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - _target = compute_target(shape, data_type); - _reference = compute_reference(shape, data_type); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(shape, data_type); - TensorType dst = create_tensor(shape, DataType::U8); - - // Create and configure function - FunctionType quantization_layer; - quantization_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - quantization_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type) - { - // Create reference - SimpleTensor src{ shape, data_type }; - - // Fill reference - fill(src); - - return reference::quantization_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class QuantizationValidationFixture : public QuantizationValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - QuantizationValidationFixedPointFixture::setup(shape, data_type); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE */ diff --git a/tests/validation_new/fixtures/ReductionOperationFixture.h b/tests/validation_new/fixtures/ReductionOperationFixture.h deleted file mode 100644 index 416aadf8d7..0000000000 --- a/tests/validation_new/fixtures/ReductionOperationFixture.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE -#define ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/ReductionOperation.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ReductionOperationValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - const TensorShape output_shape = get_output_shape(shape, axis); - _target = compute_target(shape, output_shape, data_type, axis, op); - _reference = compute_reference(shape, output_shape, data_type, axis, op); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create tensors - TensorType src = create_tensor(src_shape, data_type); - TensorType dst = create_tensor(dst_shape, data_type); - - // Create and configure function - FunctionType reduction_func; - reduction_func.configure(&src, &dst, axis, op); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - reduction_func.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &src_shape, const TensorShape &dst_shape, DataType data_type, unsigned int axis, ReductionOperation op) - { - // Create reference - SimpleTensor src{ src_shape, data_type }; - - // Fill reference - fill(src); - - return reference::reduction_operation(src, dst_shape, axis, op); - } - - TensorType _target{}; - SimpleTensor _reference{}; - -private: - TensorShape get_output_shape(TensorShape shape, unsigned int axis) - { - TensorShape output_shape(shape); - output_shape.set(axis, 1); - return output_shape; - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_REDUCTION_OPERATION_FIXTURE */ diff --git a/tests/validation_new/fixtures/ScaleFixture.h b/tests/validation_new/fixtures/ScaleFixture.h deleted file mode 100644 index 74dc0d6816..0000000000 --- a/tests/validation_new/fixtures/ScaleFixture.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SCALE_FIXTURE -#define ARM_COMPUTE_TEST_SCALE_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/Scale.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class ScaleValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, InterpolationPolicy policy, BorderMode border_mode) - { - _shape = shape; - _policy = policy; - _border_mode = border_mode; - _data_type = data_type; - - std::mt19937 generator(library->seed()); - std::uniform_real_distribution distribution_float(0.25, 4); - const float scale_x = distribution_float(generator); - const float scale_y = distribution_float(generator); - std::uniform_int_distribution distribution_u8(0, 255); - uint8_t constant_border_value = distribution_u8(generator); - - _target = compute_target(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - _reference = compute_reference(shape, scale_x, scale_y, policy, border_mode, constant_border_value); - } - -protected: - template - void fill(U &&tensor) - { - library->fill_tensor_uniform(tensor, 0); - } - - TensorType compute_target(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create tensors - TensorType src = create_tensor(shape, _data_type); - TensorShape shape_scaled(shape); - shape_scaled.set(0, shape[0] * scale_x); - shape_scaled.set(1, shape[1] * scale_y); - TensorType dst = create_tensor(shape_scaled, _data_type); - - // Create and configure function - FunctionType scale; - - scale.configure(&src, &dst, policy, border_mode, constant_border_value); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - scale.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, const float scale_x, const float scale_y, - InterpolationPolicy policy, BorderMode border_mode, uint8_t constant_border_value) - { - // Create reference - SimpleTensor src{ shape, _data_type }; - - // Fill reference - fill(src); - - return reference::scale(src, scale_x, scale_y, policy, border_mode, constant_border_value); - } - - TensorType _target{}; - SimpleTensor _reference{}; - TensorShape _shape{}; - InterpolationPolicy _policy{}; - BorderMode _border_mode{}; - DataType _data_type{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SCALE_FIXTURE */ \ No newline at end of file diff --git a/tests/validation_new/fixtures/SoftmaxLayerFixture.h b/tests/validation_new/fixtures/SoftmaxLayerFixture.h deleted file mode 100644 index c6f3d2216f..0000000000 --- a/tests/validation_new/fixtures/SoftmaxLayerFixture.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#ifndef ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/Tensor.h" -#include "framework/Asserts.h" -#include "framework/Fixture.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/validation_new/CPP/SoftmaxLayer.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -template -class SoftmaxValidationFixedPointFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape shape, DataType data_type, int fractional_bits) - { - _fractional_bits = fractional_bits; - - _target = compute_target(shape, data_type, fractional_bits); - _reference = compute_reference(shape, data_type, fractional_bits); - } - -protected: - template - void fill(U &&tensor) - { - if(_fractional_bits == 0) - { - std::uniform_real_distribution<> distribution(-1000.f, 1000.f); - library->fill(tensor, distribution, 0); - } - else - { - const int one_fixed = 1 << _fractional_bits; - std::uniform_int_distribution<> distribution(-one_fixed, one_fixed); - library->fill(tensor, distribution, 0); - } - } - - TensorType compute_target(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create tensors - TensorType src = create_tensor(shape, data_type, 1, fixed_point_position); - TensorType dst = create_tensor(shape, data_type, 1, fixed_point_position); - - // Create and configure function - FunctionType smx_layer; - smx_layer.configure(&src, &dst); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Fill tensors - fill(AccessorType(src)); - - // Compute function - smx_layer.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &shape, DataType data_type, int fixed_point_position = 0) - { - // Create reference - SimpleTensor src{ shape, data_type, 1, fixed_point_position }; - - // Fill reference - fill(src); - - return reference::softmax_layer(src); - } - - TensorType _target{}; - SimpleTensor _reference{}; - int _fractional_bits{}; -}; - -template -class SoftmaxValidationFixture : public SoftmaxValidationFixedPointFixture -{ -public: - template - void setup(TensorShape shape, DataType data_type) - { - SoftmaxValidationFixedPointFixture::setup(shape, data_type, 0); - } -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_SOFTMAX_LAYER_FIXTURE */ -- cgit v1.2.1