Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2019-2020 Arm Limited. |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/runtime/BlobLifetimeManager.h" |
| 25 | #include "arm_compute/runtime/GLES_COMPUTE/GCBufferAllocator.h" |
| 26 | #include "arm_compute/runtime/GLES_COMPUTE/functions/GCNormalizationLayer.h" |
| 27 | #include "arm_compute/runtime/MemoryGroup.h" |
| 28 | #include "arm_compute/runtime/MemoryManagerOnDemand.h" |
| 29 | #include "arm_compute/runtime/PoolManager.h" |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 30 | #include "tests/AssetsLibrary.h" |
| 31 | #include "tests/GLES_COMPUTE/GCAccessor.h" |
| 32 | #include "tests/Globals.h" |
| 33 | #include "tests/Utils.h" |
| 34 | #include "tests/framework/Asserts.h" |
| 35 | #include "tests/framework/Macros.h" |
| 36 | #include "tests/framework/datasets/Datasets.h" |
| 37 | #include "tests/validation/fixtures/UNIT/DynamicTensorFixture.h" |
| 38 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
Michalis Spyrou | 5cb49dc | 2019-12-03 13:42:25 +0000 | [diff] [blame] | 45 | #ifndef DOXYGEN_SKIP_THIS |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 46 | using GCNormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, GCNormalizationLayer, IGCTensor>; |
| 47 | template <> |
| 48 | void GCNormLayerWrapper::configure(IGCTensor *src, IGCTensor *dst) |
| 49 | { |
| 50 | _func.configure(src, dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3)); |
| 51 | } |
Michalis Spyrou | 5cb49dc | 2019-12-03 13:42:25 +0000 | [diff] [blame] | 52 | #endif // DOXYGEN_SKIP_THIS |
| 53 | |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 54 | TEST_SUITE(GC) |
| 55 | TEST_SUITE(UNIT) |
| 56 | TEST_SUITE(DynamicTensor) |
| 57 | |
Georgios Pinitas | 2ff0009 | 2019-09-30 16:50:08 +0100 | [diff] [blame] | 58 | using BlobMemoryManagementService = MemoryManagementService<GCBufferAllocator, BlobLifetimeManager, PoolManager, MemoryManagerOnDemand>; |
| 59 | using GCDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<GCTensor, GCAccessor, BlobMemoryManagementService, GCNormLayerWrapper>; |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 60 | |
| 61 | /** Tests the memory manager with dynamic input and output tensors. |
| 62 | * |
| 63 | * Create and manage the tensors needed to run a simple function. After the function is executed, |
| 64 | * change the input and output size requesting more memory and go through the manage/allocate process. |
| 65 | * The memory manager should be able to update the inner structures and allocate the requested memory |
| 66 | * */ |
Michalis Spyrou | cac09dc | 2020-11-24 00:16:49 +0000 | [diff] [blame] | 67 | FIXTURE_DATA_TEST_CASE(DynamicTensorType3Single, GCDynamicTensorType3SingleFunction, framework::DatasetMode::NIGHTLY, |
Georgios Pinitas | b785dd4 | 2019-09-19 12:09:32 +0100 | [diff] [blame] | 68 | framework::dataset::zip(framework::dataset::make("Level0Shape", { TensorShape(12U, 11U, 3U), TensorShape(256U, 8U, 12U) }), |
| 69 | framework::dataset::make("Level1Shape", { TensorShape(67U, 31U, 15U), TensorShape(11U, 2U, 3U) }))) |
| 70 | { |
| 71 | ARM_COMPUTE_EXPECT(internal_l0.size() == internal_l1.size(), framework::LogLevel::ERRORS); |
| 72 | ARM_COMPUTE_EXPECT(cross_l0.size() == cross_l1.size(), framework::LogLevel::ERRORS); |
| 73 | |
| 74 | const unsigned int internal_size = internal_l0.size(); |
| 75 | const unsigned int cross_size = cross_l0.size(); |
| 76 | if(input_l0.total_size() < input_l1.total_size()) |
| 77 | { |
| 78 | for(unsigned int i = 0; i < internal_size; ++i) |
| 79 | { |
| 80 | ARM_COMPUTE_EXPECT(internal_l0[i].size < internal_l1[i].size, framework::LogLevel::ERRORS); |
| 81 | } |
| 82 | for(unsigned int i = 0; i < cross_size; ++i) |
| 83 | { |
| 84 | ARM_COMPUTE_EXPECT(cross_l0[i].size < cross_l1[i].size, framework::LogLevel::ERRORS); |
| 85 | } |
| 86 | } |
| 87 | else |
| 88 | { |
| 89 | for(unsigned int i = 0; i < internal_size; ++i) |
| 90 | { |
| 91 | ARM_COMPUTE_EXPECT(internal_l0[i].size == internal_l1[i].size, framework::LogLevel::ERRORS); |
| 92 | } |
| 93 | for(unsigned int i = 0; i < cross_size; ++i) |
| 94 | { |
| 95 | ARM_COMPUTE_EXPECT(cross_l0[i].size == cross_l1[i].size, framework::LogLevel::ERRORS); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | TEST_SUITE_END() // DynamicTensor |
| 101 | TEST_SUITE_END() // UNIT |
| 102 | TEST_SUITE_END() // GC |
| 103 | } // namespace validation |
| 104 | } // namespace test |
| 105 | } // namespace arm_compute |