diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/validation/CL/UNIT/DynamicTensor.cpp | 105 | ||||
-rw-r--r-- | tests/validation/GLES_COMPUTE/UNIT/DynamicTensor.cpp | 105 | ||||
-rw-r--r-- | tests/validation/NEON/UNIT/DynamicTensor.cpp | 13 | ||||
-rw-r--r-- | tests/validation/fixtures/UNIT/DynamicTensorFixture.h | 38 |
4 files changed, 249 insertions, 12 deletions
diff --git a/tests/validation/CL/UNIT/DynamicTensor.cpp b/tests/validation/CL/UNIT/DynamicTensor.cpp new file mode 100644 index 0000000000..38acbd5c3a --- /dev/null +++ b/tests/validation/CL/UNIT/DynamicTensor.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 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/runtime/BlobLifetimeManager.h" +#include "arm_compute/runtime/CL/CLBufferAllocator.h" +#include "arm_compute/runtime/CL/functions/CLL2NormalizeLayer.h" +#include "arm_compute/runtime/MemoryGroup.h" +#include "arm_compute/runtime/MemoryManagerOnDemand.h" +#include "arm_compute/runtime/PoolManager.h" +#include "support/ToolchainSupport.h" +#include "tests/AssetsLibrary.h" +#include "tests/CL/CLAccessor.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/fixtures/UNIT/DynamicTensorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +using CLL2NormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, CLL2NormalizeLayer, ICLTensor>; +template <> +void CLL2NormLayerWrapper::configure(ICLTensor *src, ICLTensor *dst) +{ + _func.configure(src, dst, 0, 0.0001f); +} +} // namespace +TEST_SUITE(CL) +TEST_SUITE(UNIT) +TEST_SUITE(DynamicTensor) + +using CLDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<CLTensor, CLAccessor, CLBufferAllocator, BlobLifetimeManager, PoolManager, MemoryManagerOnDemand, CLL2NormLayerWrapper>; + +/** Tests the memory manager with dynamic input and output tensors. + * + * Create and manage the tensors needed to run a simple function. After the function is executed, + * change the input and output size requesting more memory and go through the manage/allocate process. + * The memory manager should be able to update the inner structures and allocate the requested memory + * */ +FIXTURE_DATA_TEST_CASE(DynamicTensorType3Single, CLDynamicTensorType3SingleFunction, framework::DatasetMode::ALL, + framework::dataset::zip(framework::dataset::make("Level0Shape", { TensorShape(12U, 11U, 3U), TensorShape(256U, 8U, 12U) }), + framework::dataset::make("Level1Shape", { TensorShape(67U, 31U, 15U), TensorShape(11U, 2U, 3U) }))) +{ + ARM_COMPUTE_EXPECT(internal_l0.size() == internal_l1.size(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(cross_l0.size() == cross_l1.size(), framework::LogLevel::ERRORS); + + const unsigned int internal_size = internal_l0.size(); + const unsigned int cross_size = cross_l0.size(); + if(input_l0.total_size() < input_l1.total_size()) + { + for(unsigned int i = 0; i < internal_size; ++i) + { + ARM_COMPUTE_EXPECT(internal_l0[i].size < internal_l1[i].size, framework::LogLevel::ERRORS); + } + for(unsigned int i = 0; i < cross_size; ++i) + { + ARM_COMPUTE_EXPECT(cross_l0[i].size < cross_l1[i].size, framework::LogLevel::ERRORS); + } + } + else + { + for(unsigned int i = 0; i < internal_size; ++i) + { + ARM_COMPUTE_EXPECT(internal_l0[i].size == internal_l1[i].size, framework::LogLevel::ERRORS); + } + for(unsigned int i = 0; i < cross_size; ++i) + { + ARM_COMPUTE_EXPECT(cross_l0[i].size == cross_l1[i].size, framework::LogLevel::ERRORS); + } + } +} + +TEST_SUITE_END() // DynamicTensor +TEST_SUITE_END() // UNIT +TEST_SUITE_END() // CL +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/GLES_COMPUTE/UNIT/DynamicTensor.cpp b/tests/validation/GLES_COMPUTE/UNIT/DynamicTensor.cpp new file mode 100644 index 0000000000..2b972843b8 --- /dev/null +++ b/tests/validation/GLES_COMPUTE/UNIT/DynamicTensor.cpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 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/runtime/BlobLifetimeManager.h" +#include "arm_compute/runtime/GLES_COMPUTE/GCBufferAllocator.h" +#include "arm_compute/runtime/GLES_COMPUTE/functions/GCNormalizationLayer.h" +#include "arm_compute/runtime/MemoryGroup.h" +#include "arm_compute/runtime/MemoryManagerOnDemand.h" +#include "arm_compute/runtime/PoolManager.h" +#include "support/ToolchainSupport.h" +#include "tests/AssetsLibrary.h" +#include "tests/GLES_COMPUTE/GCAccessor.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Asserts.h" +#include "tests/framework/Macros.h" +#include "tests/framework/datasets/Datasets.h" +#include "tests/validation/fixtures/UNIT/DynamicTensorFixture.h" + +namespace arm_compute +{ +namespace test +{ +namespace validation +{ +namespace +{ +using GCNormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, GCNormalizationLayer, IGCTensor>; +template <> +void GCNormLayerWrapper::configure(IGCTensor *src, IGCTensor *dst) +{ + _func.configure(src, dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3)); +} +} // namespace +TEST_SUITE(GC) +TEST_SUITE(UNIT) +TEST_SUITE(DynamicTensor) + +using GCDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<GCTensor, GCAccessor, GCBufferAllocator, BlobLifetimeManager, PoolManager, MemoryManagerOnDemand, GCNormLayerWrapper>; + +/** Tests the memory manager with dynamic input and output tensors. + * + * Create and manage the tensors needed to run a simple function. After the function is executed, + * change the input and output size requesting more memory and go through the manage/allocate process. + * The memory manager should be able to update the inner structures and allocate the requested memory + * */ +FIXTURE_DATA_TEST_CASE(DynamicTensorType3Single, GCDynamicTensorType3SingleFunction, framework::DatasetMode::ALL, + framework::dataset::zip(framework::dataset::make("Level0Shape", { TensorShape(12U, 11U, 3U), TensorShape(256U, 8U, 12U) }), + framework::dataset::make("Level1Shape", { TensorShape(67U, 31U, 15U), TensorShape(11U, 2U, 3U) }))) +{ + ARM_COMPUTE_EXPECT(internal_l0.size() == internal_l1.size(), framework::LogLevel::ERRORS); + ARM_COMPUTE_EXPECT(cross_l0.size() == cross_l1.size(), framework::LogLevel::ERRORS); + + const unsigned int internal_size = internal_l0.size(); + const unsigned int cross_size = cross_l0.size(); + if(input_l0.total_size() < input_l1.total_size()) + { + for(unsigned int i = 0; i < internal_size; ++i) + { + ARM_COMPUTE_EXPECT(internal_l0[i].size < internal_l1[i].size, framework::LogLevel::ERRORS); + } + for(unsigned int i = 0; i < cross_size; ++i) + { + ARM_COMPUTE_EXPECT(cross_l0[i].size < cross_l1[i].size, framework::LogLevel::ERRORS); + } + } + else + { + for(unsigned int i = 0; i < internal_size; ++i) + { + ARM_COMPUTE_EXPECT(internal_l0[i].size == internal_l1[i].size, framework::LogLevel::ERRORS); + } + for(unsigned int i = 0; i < cross_size; ++i) + { + ARM_COMPUTE_EXPECT(cross_l0[i].size == cross_l1[i].size, framework::LogLevel::ERRORS); + } + } +} + +TEST_SUITE_END() // DynamicTensor +TEST_SUITE_END() // UNIT +TEST_SUITE_END() // GC +} // namespace validation +} // namespace test +} // namespace arm_compute diff --git a/tests/validation/NEON/UNIT/DynamicTensor.cpp b/tests/validation/NEON/UNIT/DynamicTensor.cpp index 731c6d1650..319aa6a8ee 100644 --- a/tests/validation/NEON/UNIT/DynamicTensor.cpp +++ b/tests/validation/NEON/UNIT/DynamicTensor.cpp @@ -36,7 +36,6 @@ #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" #include "tests/validation/fixtures/UNIT/DynamicTensorFixture.h" -#include <arm_compute/runtime/OffsetMemoryPool.h> namespace arm_compute { @@ -44,11 +43,19 @@ namespace test { namespace validation { +namespace +{ +using NENormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, NENormalizationLayer, ITensor>; +template <> +void NENormLayerWrapper::configure(arm_compute::ITensor *src, arm_compute::ITensor *dst) +{ + _func.configure(src, dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3)); +} +} // namespace TEST_SUITE(NEON) TEST_SUITE(UNIT) TEST_SUITE(DynamicTensor) - -using NEDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<Tensor, Accessor, Allocator, OffsetLifetimeManager, PoolManager, MemoryManagerOnDemand, NENormalizationLayer>; +using NEDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<Tensor, Accessor, Allocator, OffsetLifetimeManager, PoolManager, MemoryManagerOnDemand, NENormLayerWrapper>; /** Tests the memory manager with dynamic input and output tensors. * diff --git a/tests/validation/fixtures/UNIT/DynamicTensorFixture.h b/tests/validation/fixtures/UNIT/DynamicTensorFixture.h index df12a4aa30..66ef6c4aff 100644 --- a/tests/validation/fixtures/UNIT/DynamicTensorFixture.h +++ b/tests/validation/fixtures/UNIT/DynamicTensorFixture.h @@ -89,6 +89,26 @@ public: MemoryGroup mg; size_t num_pools; }; + +template <typename MemoryMgrType, typename FuncType, typename ITensorType> +class SimpleFunctionWrapper +{ +public: + SimpleFunctionWrapper(std::shared_ptr<MemoryMgrType> mm) + : _func(mm) + { + } + void configure(ITensorType *src, ITensorType *dst) + { + } + void run() + { + _func.run(); + } + +private: + FuncType _func; +}; } // namespace /** Simple test case to run a single function with different shapes twice. @@ -102,7 +122,7 @@ template <typename TensorType, typename LifetimeMgrType, typename PoolMgrType, typename MemoryManagerType, - typename NormalizationFunctionType> + typename SimpleFunctionWrapperType> class DynamicTensorType3SingleFunction : public framework::Fixture { using T = float; @@ -131,15 +151,15 @@ protected: // Level 0 // Create tensors - TensorType src = create_tensor<Tensor>(level_0, DataType::F32, 1); - TensorType dst = create_tensor<Tensor>(level_0, DataType::F32, 1); + TensorType src = create_tensor<TensorType>(level_0, DataType::F32, 1); + TensorType dst = create_tensor<TensorType>(level_0, DataType::F32, 1); serv_cross.mg.manage(&src); serv_cross.mg.manage(&dst); // Create and configure function - NormalizationFunctionType norm_layer(serv_internal.mm); - norm_layer.configure(&src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3)); + SimpleFunctionWrapperType layer(serv_internal.mm); + layer.configure(&src, &dst); ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS); ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS); @@ -163,8 +183,8 @@ protected: // Acquire memory manager, fill tensors and compute functions serv_cross.mg.acquire(); - arm_compute::test::library->fill_tensor_value(Accessor(src), 12.f); - norm_layer.run(); + arm_compute::test::library->fill_tensor_value(AccessorType(src), 12.f); + layer.run(); serv_cross.mg.release(); // Clear manager @@ -184,7 +204,7 @@ protected: serv_cross.mg.manage(&dst); // Re-configure the function - norm_layer.configure(&src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3)); + layer.configure(&src, &dst); // Allocate tensors src.allocator()->allocate(); @@ -203,7 +223,7 @@ protected: // Compute functions serv_cross.mg.acquire(); arm_compute::test::library->fill_tensor_value(AccessorType(src), 12.f); - norm_layer.run(); + layer.run(); serv_cross.mg.release(); // Clear manager |