From 9fb1159e2501f276a27d32264bece54b3d42d258 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 26 Apr 2018 20:34:58 +0100 Subject: COMPMID-1074: Rename WinograLayer.cpp to WinogradConvolutionLayer.cpp Change-Id: Iccac7cd6cb458469568d0cd6fb36b262353f4188 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129261 Tested-by: Jenkins Reviewed-by: Pablo Tello --- tests/validation/CL/Winograd.cpp | 2 +- tests/validation/NEON/ConvolutionLayer.cpp | 8 +- .../fixtures/WinogradConvolutionLayerFixture.h | 389 +++++++++++++++++++++ tests/validation/fixtures/WinogradLayerFixture.h | 389 --------------------- 4 files changed, 394 insertions(+), 394 deletions(-) create mode 100644 tests/validation/fixtures/WinogradConvolutionLayerFixture.h delete mode 100644 tests/validation/fixtures/WinogradLayerFixture.h (limited to 'tests/validation') diff --git a/tests/validation/CL/Winograd.cpp b/tests/validation/CL/Winograd.cpp index 6e673a5f96..30d8d751af 100644 --- a/tests/validation/CL/Winograd.cpp +++ b/tests/validation/CL/Winograd.cpp @@ -41,7 +41,7 @@ #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" #include "tests/validation/Validation.h" -#include "tests/validation/fixtures/WinogradLayerFixture.h" +#include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" namespace arm_compute { diff --git a/tests/validation/NEON/ConvolutionLayer.cpp b/tests/validation/NEON/ConvolutionLayer.cpp index 3a365253cb..8b2e21e796 100644 --- a/tests/validation/NEON/ConvolutionLayer.cpp +++ b/tests/validation/NEON/ConvolutionLayer.cpp @@ -24,7 +24,7 @@ #include "arm_compute/core/Types.h" #include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h" #include "arm_compute/runtime/NEON/functions/NEGEMMConvolutionLayer.h" -#include "arm_compute/runtime/NEON/functions/NEWinogradLayer.h" +#include "arm_compute/runtime/NEON/functions/NEWinogradConvolutionLayer.h" #include "arm_compute/runtime/Tensor.h" #include "arm_compute/runtime/TensorAllocator.h" #include "tests/NEON/Accessor.h" @@ -37,7 +37,7 @@ #include "tests/framework/datasets/Datasets.h" #include "tests/validation/Validation.h" #include "tests/validation/fixtures/ConvolutionLayerFixture.h" -#include "tests/validation/fixtures/WinogradLayerFixture.h" +#include "tests/validation/fixtures/WinogradConvolutionLayerFixture.h" namespace arm_compute { @@ -109,10 +109,10 @@ TEST_SUITE_END() TEST_SUITE(WinogradLayer) template -using NEWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture; +using NEWinogradConvolutionLayerFixture = WinogradConvolutionLayerValidationFixture; template -using NEWinogradConvolutionLayerNoBiasFixture = WinogradConvolutionLayerValidationFixture; +using NEWinogradConvolutionLayerNoBiasFixture = WinogradConvolutionLayerValidationFixture; TEST_SUITE(FP32) FIXTURE_DATA_TEST_CASE(RunSmall, NEWinogradConvolutionLayerFixture, framework::DatasetMode::PRECOMMIT, diff --git a/tests/validation/fixtures/WinogradConvolutionLayerFixture.h b/tests/validation/fixtures/WinogradConvolutionLayerFixture.h new file mode 100644 index 0000000000..249f9d5649 --- /dev/null +++ b/tests/validation/fixtures/WinogradConvolutionLayerFixture.h @@ -0,0 +1,389 @@ +/* + * Copyright (c) 2018 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_WINOGRAD_LAYER_FIXTURE +#define ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "arm_compute/core/utils/misc/ShapeCalculator.h" +#include "tests/AssetsLibrary.h" +#include "tests/Globals.h" +#include "tests/IAccessor.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Fixture.h" +#include "tests/validation/Helpers.h" +#include "tests/validation/reference/ActivationLayer.h" +#include "tests/validation/reference/ConvolutionLayer.h" +#include "tests/validation/reference/Utils.h" +#include "tests/validation/reference/Winograd.h" + +#include + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +using namespace arm_compute::misc::shape_calculator; + +template +class WinogradConvolutionLayerValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, Size2D dilation, DataType data_type, ActivationLayerInfo act_info) + { + ARM_COMPUTE_UNUSED(dilation); + + _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); + _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); + } + +protected: + template + void fill(U &&tensor, int i, float min, float max) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(min, max); + library->fill(tensor, distribution, i); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + library->fill_tensor_uniform(tensor, i); + break; + } + } + } + + 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, ActivationLayerInfo act_info) + { + // Create tensors + TensorType src = create_tensor(input_shape, data_type, 1); + TensorType weights = create_tensor(weights_shape, data_type, 1); + TensorType bias = create_tensor(bias_shape, data_type, 1); + TensorType dst = create_tensor(output_shape, data_type, 1); + + // Create and configure function + FunctionType conv; + ARM_COMPUTE_EXPECT(static_cast(conv.validate(src.info(), weights.info(), (use_bias) ? bias.info() : nullptr, dst.info(), info, act_info)), framework::LogLevel::ERRORS); + conv.configure(&src, &weights, (use_bias) ? &bias : nullptr, &dst, info, act_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(); + dst.allocator()->allocate(); + bias.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, -1.f, 1.f); + fill(AccessorType(weights), 1, -1.f, 1.f); + fill(AccessorType(bias), 2, -1.f, 1.f); + + // Compute Winograd Convolution 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, ActivationLayerInfo act_info) + { + // Create reference + SimpleTensor src{ input_shape, data_type, 1 }; + SimpleTensor weights{ weights_shape, data_type, 1 }; + SimpleTensor bias{ bias_shape, data_type, 1 }; + + // Fill reference + fill(src, 0, -1.f, 1.f); + fill(weights, 1, -1.f, 1.f); + if(use_bias) + { + fill(bias, 2, -1.f, 1.f); + } + else + { + fill(bias, 2, 0.f, 0.f); + } + + SimpleTensor conv_out = reference::convolution_layer(src, weights, bias, output_shape, info); + + return (act_info.enabled()) ? reference::activation_layer(conv_out, act_info) : conv_out; + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; + +template +class WinogradInputTransformValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, WinogradInfo winograd_info, DataLayout data_layout, DataType data_type) + { + TensorShape output_shape = compute_winograd_input_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); + + _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); + _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); + } + +protected: + template + void fill(U &&tensor, int i, float min, float max) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(min, max); + library->fill(tensor, distribution, i); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + library->fill_tensor_uniform(tensor, i); + break; + } + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) + { + TensorType src = create_tensor(input_shape, data_type, 1, 0, QuantizationInfo(), data_layout); + TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), data_layout); + + // Create and configure function + FunctionType transf; + transf.configure(&src, &dst, winograd_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), 0, -1.f, 1.f); + + // Compute Winograd input transform function + transf.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) + { + // Create reference + SimpleTensor src{ input_shape, data_type, 1, 0, QuantizationInfo(), data_layout }; + + // Fill reference + fill(src, 0, -1.f, 1.f); + + return reference::winograd_input_transform(src, output_shape, winograd_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; + +template +class WinogradFilterTransformValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, Size2D output_tile, DataLayout data_layout, DataType data_type) + { + WinogradInfo winograd_info(output_tile, Size2D(input_shape[0], input_shape[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */); + TensorShape output_shape = compute_winograd_filter_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); + + _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); + _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); + } + +protected: + template + void fill(U &&tensor, int i, float min, float max) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(min, max); + library->fill(tensor, distribution, i); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + library->fill_tensor_uniform(tensor, i); + break; + } + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(input_shape, data_type, 1, 0, QuantizationInfo(), data_layout); + TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), data_layout); + + // Create and configure function + FunctionType filter_transform; + filter_transform.configure(&src, &dst, winograd_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), 0, -1.f, 1.f); + + filter_transform.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) + { + // Create reference + SimpleTensor src{ input_shape, data_type, 1, 0, QuantizationInfo(), data_layout }; + + // Fill reference + fill(src, 0, -1.f, 1.f); + + return reference::winograd_filter_transform(src, output_shape, winograd_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; + +template +class WinogradOutputTransformValidationFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape input_shape, WinogradInfo winograd_info, DataType data_type) + { + TensorShape output_shape = compute_winograd_output_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); + + _target = compute_target(input_shape, output_shape, winograd_info, data_type); + _reference = compute_reference(input_shape, output_shape, winograd_info, data_type); + } + +protected: + template + void fill(U &&tensor, int i, float min, float max) + { + switch(tensor.data_type()) + { + case DataType::F32: + { + std::uniform_real_distribution<> distribution(min, max); + library->fill(tensor, distribution, i); + break; + } + default: + { + ARM_COMPUTE_ERROR("Not supported"); + library->fill_tensor_uniform(tensor, i); + break; + } + } + } + + TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataType data_type) + { + // Create tensors + TensorType src = create_tensor(input_shape, data_type); + TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), winograd_info.output_data_layout); + + // Create and configure function + FunctionType output_transform; + output_transform.configure(&src, nullptr, &dst, winograd_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), 0, -1.f, 1.f); + + output_transform.run(); + + return dst; + } + + SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataType data_type) + { + // Create reference + SimpleTensor src{ input_shape, data_type }; + + // Fill reference + fill(src, 0, -1.f, 1.f); + + return reference::winograd_output_transform(src, output_shape, winograd_info); + } + + TensorType _target{}; + SimpleTensor _reference{}; +}; +} // namespace validation +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE */ diff --git a/tests/validation/fixtures/WinogradLayerFixture.h b/tests/validation/fixtures/WinogradLayerFixture.h deleted file mode 100644 index 173444ccd8..0000000000 --- a/tests/validation/fixtures/WinogradLayerFixture.h +++ /dev/null @@ -1,389 +0,0 @@ -/* - * Copyright (c) 2017-2018 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_WINOGRAD_LAYER_FIXTURE -#define ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/core/utils/misc/ShapeCalculator.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/IAccessor.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Fixture.h" -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/ActivationLayer.h" -#include "tests/validation/reference/ConvolutionLayer.h" -#include "tests/validation/reference/Utils.h" -#include "tests/validation/reference/Winograd.h" - -#include - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -using namespace arm_compute::misc::shape_calculator; - -template -class WinogradConvolutionLayerValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, Size2D dilation, DataType data_type, ActivationLayerInfo act_info) - { - ARM_COMPUTE_UNUSED(dilation); - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info, data_type, act_info); - } - -protected: - template - void fill(U &&tensor, int i, float min, float max) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - library->fill_tensor_uniform(tensor, i); - break; - } - } - } - - 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, ActivationLayerInfo act_info) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1); - TensorType weights = create_tensor(weights_shape, data_type, 1); - TensorType bias = create_tensor(bias_shape, data_type, 1); - TensorType dst = create_tensor(output_shape, data_type, 1); - - // Create and configure function - FunctionType conv; - ARM_COMPUTE_EXPECT(static_cast(conv.validate(src.info(), weights.info(), (use_bias) ? bias.info() : nullptr, dst.info(), info, act_info)), framework::LogLevel::ERRORS); - conv.configure(&src, &weights, (use_bias) ? &bias : nullptr, &dst, info, act_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(); - dst.allocator()->allocate(); - bias.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, -1.f, 1.f); - fill(AccessorType(weights), 1, -1.f, 1.f); - fill(AccessorType(bias), 2, -1.f, 1.f); - - // Compute Winograd Convolution 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, ActivationLayerInfo act_info) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1 }; - SimpleTensor weights{ weights_shape, data_type, 1 }; - SimpleTensor bias{ bias_shape, data_type, 1 }; - - // Fill reference - fill(src, 0, -1.f, 1.f); - fill(weights, 1, -1.f, 1.f); - if(use_bias) - { - fill(bias, 2, -1.f, 1.f); - } - else - { - fill(bias, 2, 0.f, 0.f); - } - - SimpleTensor conv_out = reference::convolution_layer(src, weights, bias, output_shape, info); - - return (act_info.enabled()) ? reference::activation_layer(conv_out, act_info) : conv_out; - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class WinogradInputTransformValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, WinogradInfo winograd_info, DataLayout data_layout, DataType data_type) - { - TensorShape output_shape = compute_winograd_input_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); - - _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); - _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); - } - -protected: - template - void fill(U &&tensor, int i, float min, float max) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - library->fill_tensor_uniform(tensor, i); - break; - } - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) - { - TensorType src = create_tensor(input_shape, data_type, 1, 0, QuantizationInfo(), data_layout); - TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), data_layout); - - // Create and configure function - FunctionType transf; - transf.configure(&src, &dst, winograd_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), 0, -1.f, 1.f); - - // Compute Winograd input transform function - transf.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, 0, QuantizationInfo(), data_layout }; - - // Fill reference - fill(src, 0, -1.f, 1.f); - - return reference::winograd_input_transform(src, output_shape, winograd_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class WinogradFilterTransformValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, Size2D output_tile, DataLayout data_layout, DataType data_type) - { - WinogradInfo winograd_info(output_tile, Size2D(input_shape[0], input_shape[1]), Size2D() /* Not needed */, PadStrideInfo() /* Not needed */, DataLayout::NCHW /* Not needed */); - TensorShape output_shape = compute_winograd_filter_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); - - _target = compute_target(input_shape, output_shape, winograd_info, data_layout, data_type); - _reference = compute_reference(input_shape, output_shape, winograd_info, data_layout, data_type); - } - -protected: - template - void fill(U &&tensor, int i, float min, float max) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - library->fill_tensor_uniform(tensor, i); - break; - } - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type, 1, 0, QuantizationInfo(), data_layout); - TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), data_layout); - - // Create and configure function - FunctionType filter_transform; - filter_transform.configure(&src, &dst, winograd_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), 0, -1.f, 1.f); - - filter_transform.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataLayout data_layout, DataType data_type) - { - // Create reference - SimpleTensor src{ input_shape, data_type, 1, 0, QuantizationInfo(), data_layout }; - - // Fill reference - fill(src, 0, -1.f, 1.f); - - return reference::winograd_filter_transform(src, output_shape, winograd_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; - -template -class WinogradOutputTransformValidationFixture : public framework::Fixture -{ -public: - template - void setup(TensorShape input_shape, WinogradInfo winograd_info, DataType data_type) - { - TensorShape output_shape = compute_winograd_output_transform_shape(TensorInfo(input_shape, 1, data_type), winograd_info); - - _target = compute_target(input_shape, output_shape, winograd_info, data_type); - _reference = compute_reference(input_shape, output_shape, winograd_info, data_type); - } - -protected: - template - void fill(U &&tensor, int i, float min, float max) - { - switch(tensor.data_type()) - { - case DataType::F32: - { - std::uniform_real_distribution<> distribution(min, max); - library->fill(tensor, distribution, i); - break; - } - default: - { - ARM_COMPUTE_ERROR("Not supported"); - library->fill_tensor_uniform(tensor, i); - break; - } - } - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataType data_type) - { - // Create tensors - TensorType src = create_tensor(input_shape, data_type); - TensorType dst = create_tensor(output_shape, data_type, 1, 0, QuantizationInfo(), winograd_info.output_data_layout); - - // Create and configure function - FunctionType output_transform; - output_transform.configure(&src, nullptr, &dst, winograd_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), 0, -1.f, 1.f); - - output_transform.run(); - - return dst; - } - - SimpleTensor compute_reference(const TensorShape &input_shape, const TensorShape &output_shape, const WinogradInfo &winograd_info, DataType data_type) - { - // Create reference - SimpleTensor src{ input_shape, data_type }; - - // Fill reference - fill(src, 0, -1.f, 1.f); - - return reference::winograd_output_transform(src, output_shape, winograd_info); - } - - TensorType _target{}; - SimpleTensor _reference{}; -}; -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_WINOGRAD_LAYER_FIXTURE */ -- cgit v1.2.1