ArmNN
 23.11
ICLTensorProxy.hpp
Go to the documentation of this file.
1 //
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 
10 namespace armnn
11 {
12 
13 class ICLTensorProxy : public arm_compute::ICLTensor
14 {
15 public:
16  ICLTensorProxy(arm_compute::ICLTensor* iclTensor) : m_DelegateTensor(iclTensor) {}
17  ICLTensorProxy(const ICLTensorProxy&) = delete;
18  ICLTensorProxy& operator=(const ICLTensorProxy&) = delete;
19  ICLTensorProxy(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 
61 protected:
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 
74 private:
75  arm_compute::ICLTensor* m_DelegateTensor{ nullptr };
76 };
77 
78 } //namespace armnn
armnn::ICLTensorProxy::info
arm_compute::ITensorInfo * info()
Definition: ICLTensorProxy.hpp:37
armnn::ICLTensorProxy
Definition: ICLTensorProxy.hpp:13
armnn::ICLTensorProxy::quantization
arm_compute::CLQuantization quantization() const
Definition: ICLTensorProxy.hpp:49
armnn::ICLTensorProxy::operator=
ICLTensorProxy & operator=(const ICLTensorProxy &)=delete
armnn::ICLTensorProxy::cl_buffer
const cl::Buffer & cl_buffer() const
Definition: ICLTensorProxy.hpp:55
armnn::ICLTensorProxy::do_map
uint8_t * do_map(cl::CommandQueue &q, bool blocking)
Definition: ICLTensorProxy.hpp:62
armnn::ICLTensorProxy::do_unmap
void do_unmap(cl::CommandQueue &q)
Definition: ICLTensorProxy.hpp:68
armnn::ICLTensorProxy::info
arm_compute::ITensorInfo * info() const
Definition: ICLTensorProxy.hpp:31
armnn::ICLTensorProxy::ICLTensorProxy
ICLTensorProxy(arm_compute::ICLTensor *iclTensor)
Definition: ICLTensorProxy.hpp:16
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::ICLTensorProxy::set
void set(arm_compute::ICLTensor *iclTensor)
Definition: ICLTensorProxy.hpp:22
armnn::ICLTensorProxy::buffer
uint8_t * buffer() const
Definition: ICLTensorProxy.hpp:43