blob: 90fd025eb7fca131b4ba35ff2506f2bcbe375c12 [file] [log] [blame]
Georgios Pinitas84b51ad2017-11-07 13:24:57 +00001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2019 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/Memory.h"
25
Georgios Pinitas99d40952018-04-23 16:26:46 +010026#include "arm_compute/runtime/MemoryRegion.h"
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000027
Georgios Pinitas99d40952018-04-23 16:26:46 +010028namespace arm_compute
29{
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010030Memory::Memory() : _region(nullptr), _region_owned(nullptr)
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000031{
32}
33
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010034Memory::Memory(const std::shared_ptr<IMemoryRegion> &memory) : _region(nullptr), _region_owned(memory)
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000035{
Georgios Pinitasdf310362018-11-14 13:16:56 +000036 _region_owned = memory;
37 _region = _region_owned.get();
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000038}
39
Felix Thomasmathibalanafd38f02023-09-27 17:46:17 +010040Memory::Memory(IMemoryRegion *memory) : _region(memory), _region_owned(nullptr)
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000041{
Georgios Pinitas99d40952018-04-23 16:26:46 +010042 _region = memory;
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000043}
44
Georgios Pinitas99d40952018-04-23 16:26:46 +010045IMemoryRegion *Memory::region()
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000046{
Georgios Pinitas99d40952018-04-23 16:26:46 +010047 return _region;
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000048}
49
Georgios Pinitas99d40952018-04-23 16:26:46 +010050IMemoryRegion *Memory::region() const
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000051{
Georgios Pinitas99d40952018-04-23 16:26:46 +010052 return _region;
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000053}
54
Georgios Pinitasdf310362018-11-14 13:16:56 +000055void Memory::set_region(IMemoryRegion *region)
Georgios Pinitas84b51ad2017-11-07 13:24:57 +000056{
Georgios Pinitasdf310362018-11-14 13:16:56 +000057 _region_owned = nullptr;
58 _region = region;
59}
60
61void Memory::set_owned_region(std::unique_ptr<IMemoryRegion> region)
62{
63 _region_owned = std::move(region);
Georgios Pinitas99d40952018-04-23 16:26:46 +010064 _region = _region_owned.get();
65}
66} // namespace arm_compute