Introduce NEUniqueTensor (#779)
author김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh0822.kim@samsung.com>
Wed, 18 Apr 2018 09:36:49 +0000 (18:36 +0900)
committer박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 18 Apr 2018 09:36:49 +0000 (18:36 +0900)
NEUniqueTensor is a tensor wrapper for arm_compute::Tensor.
This is similar to CLUniqueTensor.

Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
src/kernel/acl/src/NEUniqueTensor.h [new file with mode: 0644]

diff --git a/src/kernel/acl/src/NEUniqueTensor.h b/src/kernel/acl/src/NEUniqueTensor.h
new file mode 100644 (file)
index 0000000..dda5bcc
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef __NNFW_KERNEL_ACL_NEUNIQUETENSOR_H__
+#define __NNFW_KERNEL_ACL_NEUNIQUETENSOR_H__
+
+#include <arm_compute/runtime/Tensor.h>
+
+namespace nnfw {
+namespace kernel {
+namespace acl {
+
+// TODO: find a way to merge CLUniqueTensor and NEUniqueTensor.
+class NEUniqueTensor
+{
+public:
+  NEUniqueTensor(const ::arm_compute::TensorInfo &info)
+  {
+    _tensor.allocator()->init(info);
+  }
+
+public:
+  // Both copy and move are not allowed
+  NEUniqueTensor(const NEUniqueTensor &) = delete;
+  NEUniqueTensor(NEUniqueTensor &&) = delete;
+
+public:
+  ~NEUniqueTensor()
+  {
+    _tensor.allocator()->free();
+  }
+
+public:
+  void allocate()
+  {
+    _tensor.allocator()->allocate();
+  }
+
+public:
+  ::arm_compute::Tensor &ref(void) { return _tensor; }
+  ::arm_compute::Tensor *ptr(void) { return &_tensor; }
+
+private:
+  ::arm_compute::Tensor _tensor;
+};
+
+} // namespace acl
+} // namespace kernel
+} // namespace nnfw
+
+#endif //__NNFW_KERNEL_ACL_NEUNIQUETENSOR_H__