From 2d2213920ba5ab95052a557dd20594a6ccb7d562 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Thu, 3 Sep 2020 15:16:37 +0100 Subject: COMPMID-3154: Deprecate NE/CL LocallyConnectedLayer Signed-off-by: Georgios Pinitas Change-Id: Ia7516fadcf3df072abf9b83aef4d9939212ce082 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3918 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- .../runtime/CL/functions/CLLocallyConnectedLayer.h | 2 + .../NEON/functions/NELocallyConnectedLayer.h | 3 +- docs/00_introduction.dox | 6 + .../CL/functions/CLLocallyConnectedLayer.cpp | 3 + tests/datasets/LocallyConnectedDataset.h | 79 ---------- tests/validation/CL/LocallyConnected.cpp | 165 --------------------- tests/validation/NEON/LocallyConnected.cpp | 159 -------------------- .../validation/fixtures/LocallyConnectedFixture.h | 136 ----------------- tests/validation/reference/LocallyConnected.cpp | 111 -------------- tests/validation/reference/LocallyConnected.h | 44 ------ 10 files changed, 13 insertions(+), 695 deletions(-) delete mode 100644 tests/datasets/LocallyConnectedDataset.h delete mode 100644 tests/validation/CL/LocallyConnected.cpp delete mode 100644 tests/validation/NEON/LocallyConnected.cpp delete mode 100644 tests/validation/fixtures/LocallyConnectedFixture.h delete mode 100644 tests/validation/reference/LocallyConnected.cpp delete mode 100644 tests/validation/reference/LocallyConnected.h diff --git a/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h b/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h index 59d0db663c..ba85c6140c 100644 --- a/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h +++ b/arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h @@ -72,6 +72,7 @@ public: * Data types supported: Same as @p input. * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. */ + ARM_COMPUTE_DEPRECATED_REL(20.11) void configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info); /** Set the input and output tensors. * @@ -85,6 +86,7 @@ public: * Data types supported: Same as @p input. * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. */ + ARM_COMPUTE_DEPRECATED_REL(20.11) void configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info); /** Static function to check if given info will lead to a valid configuration of @ref CLLocallyConnectedLayer * diff --git a/arm_compute/runtime/NEON/functions/NELocallyConnectedLayer.h b/arm_compute/runtime/NEON/functions/NELocallyConnectedLayer.h index e76f6b3515..dbcaa297ab 100644 --- a/arm_compute/runtime/NEON/functions/NELocallyConnectedLayer.h +++ b/arm_compute/runtime/NEON/functions/NELocallyConnectedLayer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Arm Limited. + * Copyright (c) 2017-2020 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -72,6 +72,7 @@ public: * Data types supported: Same as @p input. * @param[in] conv_info Contains padding and stride information described in @ref PadStrideInfo. */ + ARM_COMPUTE_DEPRECATED_REL(20.11) void configure(const ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *output, const PadStrideInfo &conv_info); /** Static function to check if given info will lead to a valid configuration of @ref NELocallyConnectedLayer * diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox index 6a44a96b0c..538fb3632b 100644 --- a/docs/00_introduction.dox +++ b/docs/00_introduction.dox @@ -248,6 +248,12 @@ v20.11 Public major release - @ref CLSoftmaxLayer - @ref CLLogSoftmaxLayer - @ref GCSoftmaxLayer + - Deprecated OpenCL kernels / functions: + - CLLocallyConnectedLayer + - CLLocallyConnectedMatrixMultiplyKernel + - Deprecated NEON kernels / functions: + - NELocallyConnectedLayer + - NELocallyConnectedMatrixMultiplyKernel v20.08 Public major release - Various bug fixes. diff --git a/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp b/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp index d501985aef..74cb47347f 100644 --- a/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp +++ b/src/runtime/CL/functions/CLLocallyConnectedLayer.cpp @@ -127,10 +127,13 @@ Status CLLocallyConnectedLayer::validate(const ITensorInfo *input, const ITensor return Status{}; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" void CLLocallyConnectedLayer::configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info) { configure(CLKernelLibrary::get().get_compile_context(), input, weights, biases, output, conv_info); } +#pragma GCC diagnostic pop void CLLocallyConnectedLayer::configure(const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info) diff --git a/tests/datasets/LocallyConnectedDataset.h b/tests/datasets/LocallyConnectedDataset.h deleted file mode 100644 index 5d2017dba7..0000000000 --- a/tests/datasets/LocallyConnectedDataset.h +++ /dev/null @@ -1,79 +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_LOCALLYCONNECTED_DATASET -#define ARM_COMPUTE_TEST_LOCALLYCONNECTED_DATASET - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -#include "tests/datasets/ConvolutionLayerDataset.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class SmallLocallyConnectedDataset final : public ConvolutionLayerDataset -{ -public: - SmallLocallyConnectedDataset() - { - // Batch size 1 - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U, 275U), TensorShape(21U, 275U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 5U, 2U, 19U, 225U), TensorShape(19U, 225U), TensorShape(15U, 15U, 19U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(17U, 31U, 2U), TensorShape(5U, 3U, 2U, 19U, 240U), TensorShape(19U, 240U), TensorShape(15U, 16U, 19U), PadStrideInfo(1, 2, 1, 1)); - // Batch size 4 - add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 3U, 5U, 21U, 275U), TensorShape(21U, 275U), TensorShape(11U, 25U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 5U, 2U, 19U, 225U), TensorShape(19U, 225U), TensorShape(15U, 15U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); - add_config(TensorShape(17U, 31U, 2U, 4U), TensorShape(5U, 3U, 2U, 19U, 240U), TensorShape(19U, 240U), TensorShape(15U, 16U, 19U, 4U), PadStrideInfo(1, 2, 1, 1)); - // FC convolution - add_config(TensorShape(1U, 1U, 1024U), TensorShape(1U, 1U, 1024U, 1001U, 1U), TensorShape(1001U, 1U), TensorShape(1U, 1U, 1001U), PadStrideInfo(1, 1, 0, 0)); - } -}; - -class LargeLocallyConnectedDataset final : public ConvolutionLayerDataset -{ -public: - LargeLocallyConnectedDataset() - { - // Batch size 1 - add_config(TensorShape(23U, 27U, 5U), TensorShape(3U, 1U, 5U, 21U, 297U), TensorShape(21U, 297U), TensorShape(11U, 27U, 21U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 16U, 132U), TensorShape(16U, 132U), TensorShape(11U, 12U, 16U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(33U, 27U, 7U), TensorShape(5U, 7U, 7U, 16U, 121U), TensorShape(16U, 121U), TensorShape(11U, 11U, 16U), PadStrideInfo(3, 2, 1, 0)); - // Batch size 4 - add_config(TensorShape(23U, 27U, 5U, 4U), TensorShape(3U, 1U, 5U, 21U, 297U), TensorShape(21U, 297U), TensorShape(11U, 27U, 21U, 4U), PadStrideInfo(2, 1, 0, 0)); - add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 5U, 7U, 16U, 132U), TensorShape(16U, 132U), TensorShape(11U, 12U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); - add_config(TensorShape(33U, 27U, 7U, 4U), TensorShape(5U, 7U, 7U, 16U, 121U), TensorShape(16U, 121U), TensorShape(11U, 11U, 16U, 4U), PadStrideInfo(3, 2, 1, 0)); - // Arbitrary batch size - add_config(TensorShape(33U, 27U, 7U, 5U), TensorShape(5U, 7U, 7U, 16U, 121U), TensorShape(16U, 121U), TensorShape(11U, 11U, 16U, 5U), PadStrideInfo(3, 2, 1, 0)); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LOCALLYCONNECTED_DATASET */ diff --git a/tests/validation/CL/LocallyConnected.cpp b/tests/validation/CL/LocallyConnected.cpp deleted file mode 100644 index d32487b99b..0000000000 --- a/tests/validation/CL/LocallyConnected.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2017-2019 Arm Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLLocallyConnectedLayer.h" -#include "tests/CL/CLAccessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets/LocallyConnectedDataset.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Macros.h" -#include "tests/framework/datasets/Datasets.h" -#include "tests/validation/Validation.h" -#include "tests/validation/fixtures/LocallyConnectedFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr AbsoluteTolerance atolerance_f32(0.00001f); /**< Absolute Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -RelativeTolerance rtolerance_f32(0.05f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(CL) -TEST_SUITE(LocallyConnected) - -// *INDENT-OFF* -// clang-format off -DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( - framework::dataset::make("InputInfo", { TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/weights - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/bias - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/output - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/weights - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/bias - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/output - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Asymmetric padding - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Padding required - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32) - }), - framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F16), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 274U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(1U, 3U, 5U, 21U, 575U), 1, DataType::F32) - })), - framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F16), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 274U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 575U), 1, DataType::F32) - })), - framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F16), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 22U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(23U, 25U, 21U), 1, DataType::F32) - })), - framework::dataset::make("PadStride", { PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 1, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(1, 1, 0, 0) - })), - framework::dataset::make("Expected", { false, false, false, false, false, false, false, false, true })), - input_info, weights_info, bias_info, output_info, conv_info, expected) -{ - bool is_valid = bool(CLLocallyConnectedLayer::validate(&input_info.clone()->set_is_resizable(false), - &weights_info.clone()->set_is_resizable(false), - &bias_info.clone()->set_is_resizable(false), - &output_info.clone()->set_is_resizable(false), - conv_info)); - ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); -} -// clang-format on -// *INDENT-ON* - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(datasets::SmallLocallyConnectedDataset(), - framework::dataset::make("DataType", DataType::F32)), - src_shape, weights_shape, bias_shape, dst_shape, info, dilation, data_type) -{ - ARM_COMPUTE_UNUSED(dilation); - - // Create tensors - CLTensor src = create_tensor(src_shape, data_type); - CLTensor weights = create_tensor(weights_shape, data_type); - CLTensor bias = create_tensor(bias_shape, data_type); - CLTensor dst = create_tensor(dst_shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - CLLocallyConnectedLayer lc; - lc.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using CLLocallyConnectedFixture = LocallyConnectedValidationFixture; -FIXTURE_DATA_TEST_CASE(RunSmall, CLLocallyConnectedFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallLocallyConnectedDataset(), - framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, rtolerance_f32, 0.f, atolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, CLLocallyConnectedFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeLocallyConnectedDataset(), - framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(CLAccessor(_target), _reference, rtolerance_f32, 0.f, atolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/NEON/LocallyConnected.cpp b/tests/validation/NEON/LocallyConnected.cpp deleted file mode 100644 index 37c77520a0..0000000000 --- a/tests/validation/NEON/LocallyConnected.cpp +++ /dev/null @@ -1,159 +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. - */ -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NELocallyConnectedLayer.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" -#include "tests/NEON/Accessor.h" -#include "tests/PaddingCalculator.h" -#include "tests/datasets/LocallyConnectedDataset.h" -#include "tests/framework/Asserts.h" -#include "tests/framework/Macros.h" -#include "tests/framework/datasets/Datasets.h" -#include "tests/validation/Validation.h" -#include "tests/validation/fixtures/LocallyConnectedFixture.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace -{ -constexpr RelativeTolerance tolerance_f32(0.0001f); /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -} // namespace - -TEST_SUITE(NEON) -TEST_SUITE(LocallyConnected) - -// *INDENT-OFF* -// clang-format off -DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip( - framework::dataset::make("InputInfo", { TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/weights - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/bias - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching data type input/output - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/weights - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/bias - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Mismatching shape input/output - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32), // Asymmetric padding - TensorInfo(TensorShape(23U, 27U, 5U), 1, DataType::F32) - }), - framework::dataset::make("WeightsInfo",{ TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F16), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 274U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(3U, 3U, 5U, 21U, 275U), 1, DataType::F32) - })), - framework::dataset::make("BiasInfo", { TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F16), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 274U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32), - TensorInfo(TensorShape(21U, 275U), 1, DataType::F32) - })), - framework::dataset::make("OutputInfo", { TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F16), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 22U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32), - TensorInfo(TensorShape(11U, 25U, 21U), 1, DataType::F32) - })), - framework::dataset::make("PadStride", { PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 0, 0), - PadStrideInfo(2, 1, 1, 0, 0, 0, DimensionRoundingType::FLOOR), - PadStrideInfo(2, 1, 0, 0) - })), - framework::dataset::make("Expected", { false, false, false, false, false, false, false, true })), - input_info, weights_info, bias_info, output_info, conv_info, expected) -{ - bool is_valid = bool(NELocallyConnectedLayer::validate(&input_info.clone()->set_is_resizable(false), - &weights_info.clone()->set_is_resizable(false), - &bias_info.clone()->set_is_resizable(false), - &output_info.clone()->set_is_resizable(false), - conv_info)); - ARM_COMPUTE_EXPECT(is_valid == expected, framework::LogLevel::ERRORS); -} -// clang-format on -// *INDENT-ON* - -DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallLocallyConnectedDataset(), datasets::LargeLocallyConnectedDataset()), - framework::dataset::make("DataType", DataType::F32)), - src_shape, weights_shape, bias_shape, dst_shape, info, dilation, data_type) -{ - ARM_COMPUTE_UNUSED(dilation); - - // Create tensors - Tensor src = create_tensor(src_shape, data_type); - Tensor weights = create_tensor(weights_shape, data_type); - Tensor bias = create_tensor(bias_shape, data_type); - Tensor dst = create_tensor(dst_shape, data_type); - - ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(weights.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(bias.info()->is_resizable(), framework::LogLevel::ERRORS); - ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); - - // Create and configure function. - NELocallyConnectedLayer lc; - lc.configure(&src, &weights, &bias, &dst, info); - - // Validate valid region - const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); - validate(dst.info()->valid_region(), dst_valid_region); -} - -template -using NELocallyConnectedFixture = LocallyConnectedValidationFixture; -FIXTURE_DATA_TEST_CASE(RunSmall, NELocallyConnectedFixture, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallLocallyConnectedDataset(), - framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} - -FIXTURE_DATA_TEST_CASE(RunLarge, NELocallyConnectedFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeLocallyConnectedDataset(), - framework::dataset::make("DataType", - DataType::F32))) -{ - // Validate output - validate(Accessor(_target), _reference, tolerance_f32); -} -TEST_SUITE_END() -TEST_SUITE_END() -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/fixtures/LocallyConnectedFixture.h b/tests/validation/fixtures/LocallyConnectedFixture.h deleted file mode 100644 index 2e2b71665b..0000000000 --- a/tests/validation/fixtures/LocallyConnectedFixture.h +++ /dev/null @@ -1,136 +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_LOCALLY_CONNECTED_FIXTURE -#define ARM_COMPUTE_TEST_LOCALLY_CONNECTED_FIXTURE - -#include "arm_compute/core/Error.h" -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/NEScheduler.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/LocallyConnected.h" -#include "tests/validation/reference/Utils.h" - -#include - -namespace arm_compute -{ -class NELocallyConnected; - -namespace test -{ -namespace validation -{ -template -class LocallyConnectedValidationFixture : public framework::Fixture -{ -public: - using TBias = typename std::conditional::type, uint8_t>::value, int32_t, T>::type; - -public: - template - void setup(TensorShape input_shape, TensorShape weights_shape, TensorShape bias_shape, TensorShape output_shape, PadStrideInfo info, Size2D dilation, DataType data_type) - { - ARM_COMPUTE_UNUSED(dilation); - - _data_type = data_type; - _bias_data_type = data_type; - - _target = compute_target(input_shape, weights_shape, bias_shape, output_shape, info); - _reference = compute_reference(input_shape, weights_shape, bias_shape, output_shape, info); - } - -protected: - template - void fill(U &&tensor, int i) - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(tensor, distribution, i); - } - - TensorType compute_target(const TensorShape &input_shape, const TensorShape &weights_shape, const TensorShape &bias_shape, const TensorShape &output_shape, const PadStrideInfo &info) - { - TensorShape reshaped_weights_shape(weights_shape); - - // Create tensors - TensorType src = create_tensor(input_shape, _data_type); - TensorType weights = create_tensor(reshaped_weights_shape, _data_type); - TensorType bias = create_tensor(bias_shape, _bias_data_type); - TensorType dst = create_tensor(output_shape, _data_type); - - // Create and configure function - FunctionType locally_connected; - locally_connected.configure(&src, &weights, &bias, &dst, info); - - // 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); - - locally_connected.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) - { - // Create reference - SimpleTensor src(input_shape, _data_type); - SimpleTensor weights(weights_shape, _data_type); - SimpleTensor bias(bias_shape, _bias_data_type); - - // Fill reference - fill(src, 0); - fill(weights, 1); - fill(bias, 2); - - return reference::locally_connected(src, weights, bias, output_shape, info); - } - - TensorType _target{}; - SimpleTensor _reference{}; - DataType _data_type{}; - DataType _bias_data_type{}; -}; - -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LOCALLY_CONNECTED_FIXTURE */ diff --git a/tests/validation/reference/LocallyConnected.cpp b/tests/validation/reference/LocallyConnected.cpp deleted file mode 100644 index a5141f291f..0000000000 --- a/tests/validation/reference/LocallyConnected.cpp +++ /dev/null @@ -1,111 +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. - */ -#include "LocallyConnected.h" - -#include "tests/validation/Helpers.h" -#include "tests/validation/reference/Convolution3d.h" -#include "tests/validation/reference/Utils.h" - -#include "tests/framework/Asserts.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor locally_connected(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info) -{ - // Create reference - SimpleTensor dst{ output_shape, src.data_type(), 1, src.quantization_info() }; - - // Compute reference - const int width_in = src.shape().x(); - const int height_in = src.shape().y(); - const int depth_in = src.shape().z(); - - const int width_out = dst.shape().x(); - const int height_out = dst.shape().y(); - const int depth_out = dst.shape().z(); - - const int width_weights = weights.shape().x(); - const int height_weights = weights.shape().y(); - const int depth_weights = weights.shape().z(); - - const int pad_left = info.pad_left(); - const int pad_top = info.pad_top(); - const int stride_xi = info.stride().first; - const int stride_yi = info.stride().second; - - auto output_wh = scaled_dimensions(width_in, height_in, width_weights, height_weights, info); - - const int start_xi = width_weights / 2 - pad_left; - const int start_yi = height_weights / 2 - pad_top; - const int end_xi = output_wh.first * stride_xi; - const int end_yi = output_wh.second * stride_yi; - const int num_batches = src.shape().total_size() / (width_in * height_in * depth_in); - - for(int r = 0; r < num_batches; ++r) - { - int count = 0; - for(int yi = start_yi; yi < start_yi + end_yi; yi += stride_yi) - { - for(int xi = start_xi; xi < start_xi + end_xi; xi += stride_xi) - { - for(int ofm = 0; ofm < depth_out; ++ofm) - { - // Compute input and output offsets - const int offset_in = r * width_in * height_in * depth_in; - const int xo = (xi - start_xi) / stride_xi; - const int yo = (yi - start_yi) / stride_yi; - const int offset_out = xo + yo * width_out + ofm * width_out * height_out + r * width_out * height_out * depth_out; - - ARM_COMPUTE_ASSERT(xo < width_out); - ARM_COMPUTE_ASSERT(yo < height_out); - - // Compute 3D convolution - convolution_3d::detail::convolution3d(src, weights, bias, dst, - offset_in, count * width_weights * height_weights * depth_weights, count, offset_out, - xi, yi, - width_in, height_in, depth_in, - width_weights, height_weights); - count++; - } - } - } - } - - return dst; -} - -// Locally Connected only supports F32 -template SimpleTensor locally_connected(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, - const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute diff --git a/tests/validation/reference/LocallyConnected.h b/tests/validation/reference/LocallyConnected.h deleted file mode 100644 index c85d0e9827..0000000000 --- a/tests/validation/reference/LocallyConnected.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017-2019 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_LOCALLY_CONNECTED_H -#define ARM_COMPUTE_TEST_LOCALLY_CONNECTED_H - -#include "tests/SimpleTensor.h" -#include "tests/validation/Helpers.h" - -namespace arm_compute -{ -namespace test -{ -namespace validation -{ -namespace reference -{ -template -SimpleTensor locally_connected(const SimpleTensor &src, const SimpleTensor &weights, const SimpleTensor &bias, const TensorShape &output_shape, const PadStrideInfo &info); -} // namespace reference -} // namespace validation -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_LOCALLY_CONNECTED_H */ -- cgit v1.2.1