From 11509c01a0adfca83e6aa4dde9fad8524f5b176d Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EA=B9=80=EC=A0=95=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Senior=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 12 Apr 2018 09:44:49 +0900 Subject: [PATCH] Extract CLUniqueTensor to another file (#578) This commit extracts CLUniqueTensor to another file in order to use this class in other OpenCL NN Layers. Signed-off-by: Junghyun Kim --- src/kernel/acl/src/CLUniqueTensor.h | 47 +++++++++++++++++++++++++++++++++++++ src/kernel/acl/src/cl/Conv2D.cpp | 35 +-------------------------- 2 files changed, 48 insertions(+), 34 deletions(-) create mode 100644 src/kernel/acl/src/CLUniqueTensor.h diff --git a/src/kernel/acl/src/CLUniqueTensor.h b/src/kernel/acl/src/CLUniqueTensor.h new file mode 100644 index 0000000..b1c487d --- /dev/null +++ b/src/kernel/acl/src/CLUniqueTensor.h @@ -0,0 +1,47 @@ +#ifndef __NNFW_KERNEL_ACL_CLUNIQUETENSOR_H__ +#define __NNFW_KERNEL_ACL_CLUNIQUETENSOR_H__ + +#include + +namespace nnfw { +namespace kernel { +namespace acl { + +class CLUniqueTensor +{ +public: + CLUniqueTensor(const ::arm_compute::TensorInfo &info) + { + _tensor.allocator()->init(info); + } + +public: + // Both copy and move are not allowed + CLUniqueTensor(const CLUniqueTensor &) = delete; + CLUniqueTensor(CLUniqueTensor &&) = delete; + +public: + ~CLUniqueTensor() + { + _tensor.allocator()->free(); + } + +public: + void allocate() + { + _tensor.allocator()->allocate(); + } + +public: + ::arm_compute::CLTensor &ref(void) { return _tensor; } + ::arm_compute::CLTensor *ptr(void) { return &_tensor; } + +private: + ::arm_compute::CLTensor _tensor; +}; + +} // namespace acl +} // namespace kernel +} // namespace nnfw + +#endif //__NNFW_KERNEL_ACL_CLUNIQUETENSOR_H__ diff --git a/src/kernel/acl/src/cl/Conv2D.cpp b/src/kernel/acl/src/cl/Conv2D.cpp index d8afe36..4c0736d 100644 --- a/src/kernel/acl/src/cl/Conv2D.cpp +++ b/src/kernel/acl/src/cl/Conv2D.cpp @@ -6,6 +6,7 @@ #include "../IO_accessor.h" #include "../util.h" #include "../shape.h" +#include "../CLUniqueTensor.h" #include @@ -125,40 +126,6 @@ namespace nnfw { namespace kernel { namespace acl { -class CLUniqueTensor -{ -public: - CLUniqueTensor(const ::arm_compute::TensorInfo &info) - { - _tensor.allocator()->init(info); - } - -public: - // Both copy and move are not allowed - CLUniqueTensor(const CLUniqueTensor &) = delete; - CLUniqueTensor(CLUniqueTensor &&) = delete; - -public: - ~CLUniqueTensor() - { - _tensor.allocator()->free(); - - } - -public: - void allocate() - { - _tensor.allocator()->allocate(); - } - -public: - ::arm_compute::CLTensor &ref(void) { return _tensor; } - ::arm_compute::CLTensor *ptr(void) { return &_tensor; } - -private: - ::arm_compute::CLTensor _tensor; -}; - // TODO move to separate file uint32_t getNumItems(const android::nn::Shape& shape) { -- 2.7.4