blob: 27b05ed55ab9e0ab830893f2c5d5f367c82c755b [file] [log] [blame]
Georgios Pinitas84b51ad2017-11-07 13:24:57 +00001/*
2 * Copyright (c) 2017 ARM Limited.
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/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
77 mm->set_allocator(&allocator);
78 mm->set_num_pools(1);
79 mm->finalize();
80 ARM_COMPUTE_EXPECT(mm->is_finalized(), framework::LogLevel::ERRORS);
81 ARM_COMPUTE_EXPECT(mm->lifetime_manager()->are_all_finalized(), framework::LogLevel::ERRORS);
82
83 // Fill tensors
84 arm_compute::test::library->fill_tensor_uniform(Accessor(src), 0);
85
86 // Compute functions
87 norm_layer_1.run();
88 norm_layer_2.run();
89}
90
91TEST_SUITE_END()
92TEST_SUITE_END()
93TEST_SUITE_END()
94} // namespace validation
95} // namespace test
96} // namespace arm_compute