aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/RefTensorHandle.cpp
diff options
context:
space:
mode:
authorMatthew Bentham <Matthew.Bentham@arm.com>2019-06-18 16:14:34 +0100
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-07-02 09:19:01 +0000
commit4cefc4135f7fbf5c2ba532a4f5b14d2811f9ed9e (patch)
tree1a7fbd6c636d83737b4e2319ed27255397921a32 /src/backends/reference/RefTensorHandle.cpp
parentfe15eff9ed2007cd10800ec356ce2e8ea4b5f9d0 (diff)
downloadarmnn-4cefc4135f7fbf5c2ba532a4f5b14d2811f9ed9e.tar.gz
IVGCVSW-3307 Introduce RefTensorHandle
Use it for intermediate tensors on reference backend. Lays the groundwork for memory management in the reference backend. Change-Id: I7d3ee132cac31bde70ae6e1b815f4f0b03d550a6 Signed-off-by: Matthew Bentham <Matthew.Bentham@arm.com>
Diffstat (limited to 'src/backends/reference/RefTensorHandle.cpp')
-rw-r--r--src/backends/reference/RefTensorHandle.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/backends/reference/RefTensorHandle.cpp b/src/backends/reference/RefTensorHandle.cpp
new file mode 100644
index 0000000000..b7670f6f6e
--- /dev/null
+++ b/src/backends/reference/RefTensorHandle.cpp
@@ -0,0 +1,45 @@
+//
+// Copyright © 2017 Arm Ltd. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+#include "RefTensorHandle.hpp"
+
+namespace armnn
+{
+
+RefTensorHandle::RefTensorHandle(const TensorInfo &tensorInfo):
+ m_TensorInfo(tensorInfo),
+ m_Memory(nullptr)
+{
+
+}
+
+RefTensorHandle::~RefTensorHandle()
+{
+ ::operator delete(m_Memory);
+}
+
+void RefTensorHandle::Allocate()
+{
+ if (m_Memory == nullptr)
+ {
+ m_Memory = ::operator new(m_TensorInfo.GetNumBytes());
+ }
+ else
+ {
+ throw InvalidArgumentException("RefTensorHandle::Allocate Trying to allocate a RefTensorHandle"
+ "that already has allocated memory.");
+ }
+}
+
+void RefTensorHandle::CopyOutTo(void* memory) const
+{
+ memcpy(memory, m_Memory, m_TensorInfo.GetNumBytes());
+}
+
+void RefTensorHandle::CopyInFrom(const void* memory)
+{
+ memcpy(m_Memory, memory, m_TensorInfo.GetNumBytes());
+}
+
+} \ No newline at end of file