blob: fff9c53d3184c3abc32172e87256a47087f4525d [file] [log] [blame]
Narumol Prangnawarat9ef36142022-01-25 15:15:34 +00001//
2// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
7#include <arm_compute/core/CL/ICLTensor.h>
8#include <arm_compute/core/ITensorInfo.h>
9
10namespace armnn
11{
12
13class ICLTensorProxy : public arm_compute::ICLTensor
14{
15public:
16 ICLTensorProxy(arm_compute::ICLTensor* iclTensor) : m_DelegateTensor(iclTensor) {}
17 ICLTensorProxy(const ICLTensorProxy&) = delete;
18 ICLTensorProxy& operator=(const ICLTensorProxy&) = delete;
19 ICLTensorProxy(ICLTensorProxy&&) = default;
20 ICLTensorProxy& operator=(ICLTensorProxy&&) = default;
21
22 void set(arm_compute::ICLTensor* iclTensor)
23 {
24 if(iclTensor != nullptr)
25 {
26 m_DelegateTensor = iclTensor;
27 }
28 }
29
30 // Inherited methods overridden:
31 arm_compute::ITensorInfo* info() const
32 {
33 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
34 return m_DelegateTensor->info();
35 }
36
37 arm_compute::ITensorInfo* info()
38 {
39 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
40 return m_DelegateTensor->info();
41 }
42
43 uint8_t* buffer() const
44 {
45 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
46 return m_DelegateTensor->buffer();
47 }
48
49 arm_compute::CLQuantization quantization() const
50 {
51 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
52 return m_DelegateTensor->quantization();
53 }
54
55 const cl::Buffer& cl_buffer() const
56 {
57 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
58 return m_DelegateTensor->cl_buffer();
59 }
60
61protected:
62 uint8_t* do_map(cl::CommandQueue& q, bool blocking)
63 {
64 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
65 m_DelegateTensor->map(q, blocking);
66 return m_DelegateTensor->buffer();
67 }
68 void do_unmap(cl::CommandQueue& q)
69 {
70 ARM_COMPUTE_ERROR_ON(m_DelegateTensor == nullptr);
71 return m_DelegateTensor->unmap(q);
72 }
73
74private:
75 arm_compute::ICLTensor* m_DelegateTensor{ nullptr };
76};
77
78} //namespace armnn