blob: b7670f6f6eac161bff534d1ed02e6fd16fe2bebd [file] [log] [blame]
Matthew Bentham4cefc412019-06-18 16:14:34 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#include "RefTensorHandle.hpp"
6
7namespace armnn
8{
9
10RefTensorHandle::RefTensorHandle(const TensorInfo &tensorInfo):
11 m_TensorInfo(tensorInfo),
12 m_Memory(nullptr)
13{
14
15}
16
17RefTensorHandle::~RefTensorHandle()
18{
19 ::operator delete(m_Memory);
20}
21
22void 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
35void RefTensorHandle::CopyOutTo(void* memory) const
36{
37 memcpy(memory, m_Memory, m_TensorInfo.GetNumBytes());
38}
39
40void RefTensorHandle::CopyInFrom(const void* memory)
41{
42 memcpy(m_Memory, memory, m_TensorInfo.GetNumBytes());
43}
44
45}