Matthew Bentham | 4cefc41 | 2019-06-18 16:14:34 +0100 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #include "RefTensorHandle.hpp" |
| 6 | |
| 7 | namespace armnn |
| 8 | { |
| 9 | |
| 10 | RefTensorHandle::RefTensorHandle(const TensorInfo &tensorInfo): |
| 11 | m_TensorInfo(tensorInfo), |
| 12 | m_Memory(nullptr) |
| 13 | { |
| 14 | |
| 15 | } |
| 16 | |
| 17 | RefTensorHandle::~RefTensorHandle() |
| 18 | { |
| 19 | ::operator delete(m_Memory); |
| 20 | } |
| 21 | |
| 22 | void RefTensorHandle::Allocate() |
| 23 | { |
| 24 | if (m_Memory == nullptr) |
| 25 | { |
| 26 | m_Memory = ::operator new(m_TensorInfo.GetNumBytes()); |
| 27 | } |
| 28 | else |
| 29 | { |
| 30 | throw InvalidArgumentException("RefTensorHandle::Allocate Trying to allocate a RefTensorHandle" |
| 31 | "that already has allocated memory."); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void RefTensorHandle::CopyOutTo(void* memory) const |
| 36 | { |
| 37 | memcpy(memory, m_Memory, m_TensorInfo.GetNumBytes()); |
| 38 | } |
| 39 | |
| 40 | void RefTensorHandle::CopyInFrom(const void* memory) |
| 41 | { |
| 42 | memcpy(m_Memory, memory, m_TensorInfo.GetNumBytes()); |
| 43 | } |
| 44 | |
| 45 | } |