Compute Library
 21.05
CLSubTensorHandle Class Referencefinal

OpenCL Sub-Tensor handle interface object. More...

#include <CLSubTensorHandle.h>

Collaboration diagram for CLSubTensorHandle:
[legend]

Public Member Functions

 CLSubTensorHandle (ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent=false)
 Default constructor. More...
 
 ~CLSubTensorHandle ()=default
 Destructor: free the tensor's memory. More...
 
 CLSubTensorHandle (CLSubTensorHandle &&)=default
 Allow instances of this class to be move constructed. More...
 
CLSubTensorHandleoperator= (CLSubTensorHandle &&)=default
 Allow instances of this class to be moved. More...
 
 CLSubTensorHandle (const CLSubTensorHandle &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLSubTensorHandleoperator= (const CLSubTensorHandle &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
void allocate () override
 Allocates backend memory for the handle. More...
 
void free () override
 Allocates backend memory for the handle. More...
 
void manage (IMemoryGroup *mg) override
 Set backend tensor to be managed by a memory group. More...
 
void map (bool blocking) override
 Maps backend tensor object. More...
 
void unmap () override
 Un-maps a backend tensor object. More...
 
void release_if_unused () override
 Releases backend tensor if is marked as unused. More...
 
arm_compute::ITensortensor () override
 Backend tensor object accessor. More...
 
const arm_compute::ITensortensor () const override
 Backend tensor object const accessor. More...
 
ITensorHandleparent_handle () override
 Return the parent tensor handle if is a subtensor else this. More...
 
bool is_subtensor () const override
 Checks if a backing tensor is a sub-tensor object or not. More...
 
Target target () const override
 Returns target type. More...
 
- Public Member Functions inherited from ITensorHandle
virtual ~ITensorHandle ()=default
 Default virtual destructor. More...
 

Detailed Description

OpenCL Sub-Tensor handle interface object.

Definition at line 38 of file CLSubTensorHandle.h.

Constructor & Destructor Documentation

◆ CLSubTensorHandle() [1/3]

CLSubTensorHandle ( ITensorHandle parent_handle,
const TensorShape shape,
const Coordinates coords,
bool  extend_parent = false 
)

Default constructor.

Parameters
[in]parent_handleParent tensor handle
[in]shapeSub-Tensor shape
[in]coordsStarting coordinates
[in]extend_parentExtends parent shape if true

Definition at line 34 of file CLSubTensorHandle.cpp.

35  : _sub_tensor(), _parent_handle(nullptr)
36 {
38  auto parent_tensor = arm_compute::utils::cast::polymorphic_downcast<ICLTensor *>(&parent_handle->tensor());
39  _sub_tensor = arm_compute::CLSubTensor(parent_tensor, shape, coords, extend_parent);
40  _parent_handle = parent_handle;
41 }
virtual arm_compute::ITensor & tensor()=0
Backend tensor object accessor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Basic implementation of the OpenCL sub-tensor interface.
Definition: CLSubTensor.h:37
ITensorHandle * parent_handle() override
Return the parent tensor handle if is a subtensor else this.

References ARM_COMPUTE_ERROR_ON, CLSubTensorHandle::parent_handle(), arm_compute::test::validation::shape, and ITensorHandle::tensor().

◆ ~CLSubTensorHandle()

~CLSubTensorHandle ( )
default

Destructor: free the tensor's memory.

◆ CLSubTensorHandle() [2/3]

Allow instances of this class to be move constructed.

◆ CLSubTensorHandle() [3/3]

CLSubTensorHandle ( const CLSubTensorHandle )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Member Function Documentation

◆ allocate()

void allocate ( )
overridevirtual

Allocates backend memory for the handle.

Implements ITensorHandle.

Definition at line 43 of file CLSubTensorHandle.cpp.

44 {
45  // noop
46 }

◆ free()

void free ( )
overridevirtual

Allocates backend memory for the handle.

Implements ITensorHandle.

Definition at line 48 of file CLSubTensorHandle.cpp.

49 {
50  // noop
51 }

◆ is_subtensor()

bool is_subtensor ( ) const
overridevirtual

Checks if a backing tensor is a sub-tensor object or not.

Returns
True if the backend tensor is a sub-tensor else false

Implements ITensorHandle.

Definition at line 90 of file CLSubTensorHandle.cpp.

91 {
92  return true;
93 }

◆ manage()

void manage ( IMemoryGroup mg)
overridevirtual

Set backend tensor to be managed by a memory group.

Parameters
[in]mgMemory group

Implements ITensorHandle.

Definition at line 53 of file CLSubTensorHandle.cpp.

54 {
56  // noop
57 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

References ARM_COMPUTE_UNUSED.

◆ map()

void map ( bool  blocking)
overridevirtual

Maps backend tensor object.

Parameters
[in]blockingFlags if the mapping operations should be blocking

Implements ITensorHandle.

Definition at line 59 of file CLSubTensorHandle.cpp.

60 {
61  _sub_tensor.map(blocking);
62 }
void map(bool blocking=true)
Enqueue a map operation of the allocated buffer.
Definition: CLSubTensor.cpp:71

References CLSubTensor::map().

◆ operator=() [1/2]

CLSubTensorHandle& operator= ( CLSubTensorHandle &&  )
default

Allow instances of this class to be moved.

◆ operator=() [2/2]

CLSubTensorHandle& operator= ( const CLSubTensorHandle )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ parent_handle()

ITensorHandle * parent_handle ( )
overridevirtual

Return the parent tensor handle if is a subtensor else this.

Returns
Parent tensor handle

Implements ITensorHandle.

Definition at line 84 of file CLSubTensorHandle.cpp.

85 {
86  ARM_COMPUTE_ERROR_ON(_parent_handle == nullptr);
87  return _parent_handle->parent_handle();
88 }
virtual ITensorHandle * parent_handle()=0
Return the parent tensor handle if is a subtensor else this.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

References ARM_COMPUTE_ERROR_ON, and ITensorHandle::parent_handle().

Referenced by CLSubTensorHandle::CLSubTensorHandle().

◆ release_if_unused()

void release_if_unused ( )
overridevirtual

Releases backend tensor if is marked as unused.

Note
This has no effect on sub-tensors
Warning
Parent tensors don't keep track of sub-tensors, thus if a parent is set as unused then all sub-tensors will be invalidated, on the other hand if a sub-tensor is marked as unused then the parent tensor won't be released

Implements ITensorHandle.

Definition at line 69 of file CLSubTensorHandle.cpp.

70 {
71  // noop
72 }

◆ target()

Target target ( ) const
overridevirtual

Returns target type.

Returns
Target type

Implements ITensorHandle.

Definition at line 95 of file CLSubTensorHandle.cpp.

96 {
97  return Target::CL;
98 }
OpenCL capable target device.

References arm_compute::graph::CL.

◆ tensor() [1/2]

arm_compute::ITensor & tensor ( )
overridevirtual

Backend tensor object accessor.

Implements ITensorHandle.

Definition at line 79 of file CLSubTensorHandle.cpp.

80 {
81  return _sub_tensor;
82 }

◆ tensor() [2/2]

const arm_compute::ITensor & tensor ( ) const
overridevirtual

Backend tensor object const accessor.

Implements ITensorHandle.

Definition at line 74 of file CLSubTensorHandle.cpp.

75 {
76  return _sub_tensor;
77 }

◆ unmap()

void unmap ( )
overridevirtual

Un-maps a backend tensor object.

Implements ITensorHandle.

Definition at line 64 of file CLSubTensorHandle.cpp.

65 {
66  _sub_tensor.unmap();
67 }
void unmap()
Enqueue an unmap operation of the allocated and mapped buffer.
Definition: CLSubTensor.cpp:76

References CLSubTensor::unmap().


The documentation for this class was generated from the following files: