blob: 431254cf945e205241b50fb43005d9bad32eff48 [file] [log] [blame]
Georgios Pinitas84b51ad2017-11-07 13:24:57 +00001/*
Georgios Pinitas9da19e92018-10-11 15:33:11 +01002 * Copyright (c) 2017-2018 ARM Limited.
Georgios Pinitas84b51ad2017-11-07 13:24:57 +00003 *
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/Allocator.h"
25#include "arm_compute/runtime/BlobLifetimeManager.h"
26#include "arm_compute/runtime/MemoryGroup.h"
27#include "arm_compute/runtime/MemoryManagerOnDemand.h"
28#include "arm_compute/runtime/NEON/functions/NENormalizationLayer.h"
29#include "arm_compute/runtime/PoolManager.h"
30#include "arm_compute/runtime/TensorAllocator.h"
31#include "support/ToolchainSupport.h"
32#include "tests/AssetsLibrary.h"
33#include "tests/Globals.h"
34#include "tests/NEON/Accessor.h"
35#include "tests/Utils.h"
36#include "tests/framework/Asserts.h"
37#include "tests/framework/Macros.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45TEST_SUITE(NEON)
46TEST_SUITE(UNIT)
47TEST_SUITE(MemoryManager)
48
49TEST_CASE(BlobMemoryManagerSimpleWithinFunctionLevel, framework::DatasetMode::ALL)
50{
51 Allocator allocator{};
52 auto lifetime_mgr = std::make_shared<BlobLifetimeManager>();
53 auto pool_mgr = std::make_shared<PoolManager>();
54 auto mm = std::make_shared<MemoryManagerOnDemand>(lifetime_mgr, pool_mgr);
55
56 // Create tensors
57 Tensor src = create_tensor<Tensor>(TensorShape(27U, 11U, 3U), DataType::F32, 1);
58 Tensor dst = create_tensor<Tensor>(TensorShape(27U, 11U, 3U), DataType::F32, 1);
59
60 // Create and configure function
61 NENormalizationLayer norm_layer_1(mm);
62 NENormalizationLayer norm_layer_2(mm);
63 norm_layer_1.configure(&src, &dst, NormalizationLayerInfo(NormType::CROSS_MAP, 3));
64 norm_layer_2.configure(&src, &dst, NormalizationLayerInfo(NormType::IN_MAP_1D, 3));
65
66 ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
67 ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
68
69 // Allocate tensors
70 src.allocator()->allocate();
71 dst.allocator()->allocate();
72
73 ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS);
74 ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS);
75
76 // Finalize memory manager
Georgios Pinitas9da19e92018-10-11 15:33:11 +010077 mm->populate(allocator, 1 /* num_pools */);
78 ARM_COMPUTE_EXPECT(mm->pool_manager()->num_pools() == 1, framework::LogLevel::ERRORS);
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000079 ARM_COMPUTE_EXPECT(mm->lifetime_manager()->are_all_finalized(), framework::LogLevel::ERRORS);
80
81 // Fill tensors
82 arm_compute::test::library->fill_tensor_uniform(Accessor(src), 0);
83
84 // Compute functions
85 norm_layer_1.run();
86 norm_layer_2.run();
Georgios Pinitas9da19e92018-10-11 15:33:11 +010087
88 // Clear manager
89 mm->clear();
90 ARM_COMPUTE_EXPECT(mm->pool_manager()->num_pools() == 0, framework::LogLevel::ERRORS);
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000091}
92
93TEST_SUITE_END()
94TEST_SUITE_END()
95TEST_SUITE_END()
96} // namespace validation
97} // namespace test
98} // namespace arm_compute