blob: 6d57f84accf69463e148cfd5fbcd24dd7a2c4ff8 [file] [log] [blame]
Georgios Pinitasb785dd42019-09-19 12:09:32 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2019-2020 Arm Limited.
Georgios Pinitasb785dd42019-09-19 12:09:32 +01003 *
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 Pinitasb785dd42019-09-19 12:09:32 +010030#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
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
Michalis Spyrou5cb49dc2019-12-03 13:42:25 +000045#ifndef DOXYGEN_SKIP_THIS
Georgios Pinitasb785dd42019-09-19 12:09:32 +010046using GCNormLayerWrapper = SimpleFunctionWrapper<MemoryManagerOnDemand, GCNormalizationLayer, IGCTensor>;
47template <>
48void GCNormLayerWrapper::configure(IGCTensor *src, IGCTensor *dst)
49{
50 _func.configure(src, dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3));
51}
Michalis Spyrou5cb49dc2019-12-03 13:42:25 +000052#endif // DOXYGEN_SKIP_THIS
53
Georgios Pinitasb785dd42019-09-19 12:09:32 +010054TEST_SUITE(GC)
55TEST_SUITE(UNIT)
56TEST_SUITE(DynamicTensor)
57
Georgios Pinitas2ff00092019-09-30 16:50:08 +010058using BlobMemoryManagementService = MemoryManagementService<GCBufferAllocator, BlobLifetimeManager, PoolManager, MemoryManagerOnDemand>;
59using GCDynamicTensorType3SingleFunction = DynamicTensorType3SingleFunction<GCTensor, GCAccessor, BlobMemoryManagementService, GCNormLayerWrapper>;
Georgios Pinitasb785dd42019-09-19 12:09:32 +010060
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 Spyroucac09dc2020-11-24 00:16:49 +000067FIXTURE_DATA_TEST_CASE(DynamicTensorType3Single, GCDynamicTensorType3SingleFunction, framework::DatasetMode::NIGHTLY,
Georgios Pinitasb785dd42019-09-19 12:09:32 +010068 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
100TEST_SUITE_END() // DynamicTensor
101TEST_SUITE_END() // UNIT
102TEST_SUITE_END() // GC
103} // namespace validation
104} // namespace test
105} // namespace arm_compute