Compute Library
 23.05
NESubTensorHandle Class Referencefinal

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

#include <NESubTensorHandle.h>

Collaboration diagram for NESubTensorHandle:
[legend]

Public Member Functions

 NESubTensorHandle (ITensorHandle *parent_handle, const TensorShape &shape, const Coordinates &coords, bool extend_parent=false)
 Default constructor. More...
 
 ~NESubTensorHandle ()=default
 Destructor: free the tensor's memory. More...
 
 NESubTensorHandle (NESubTensorHandle &&)=default
 Allow instances of this class to be move constructed. More...
 
NESubTensorHandleoperator= (NESubTensorHandle &&)=default
 Allow instances of this class to be moved. More...
 
 NESubTensorHandle (const NESubTensorHandle &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NESubTensorHandleoperator= (const NESubTensorHandle &)=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

CPU Sub-Tensor handle interface object.

Definition at line 38 of file NESubTensorHandle.h.

Constructor & Destructor Documentation

◆ NESubTensorHandle() [1/3]

NESubTensorHandle ( 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 32 of file NESubTensorHandle.cpp.

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

33  : _sub_tensor(), _parent_handle(nullptr)
34 {
36  _sub_tensor = arm_compute::SubTensor(&parent_handle->tensor(), shape, coords, extend_parent);
37  _parent_handle = parent_handle;
38 }
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
ITensorHandle * parent_handle() override
Return the parent tensor handle if is a subtensor else this.
Basic implementation of the sub-tensor interface.
Definition: SubTensor.h:37

◆ ~NESubTensorHandle()

~NESubTensorHandle ( )
default

Destructor: free the tensor's memory.

◆ NESubTensorHandle() [2/3]

Allow instances of this class to be move constructed.

◆ NESubTensorHandle() [3/3]

NESubTensorHandle ( const NESubTensorHandle )
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 40 of file NESubTensorHandle.cpp.

41 {
42  // noop
43 }

◆ free()

void free ( )
overridevirtual

Allocates backend memory for the handle.

Implements ITensorHandle.

Definition at line 45 of file NESubTensorHandle.cpp.

46 {
47  // noop
48 }

◆ 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 87 of file NESubTensorHandle.cpp.

88 {
89  return true;
90 }

◆ 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 50 of file NESubTensorHandle.cpp.

References ARM_COMPUTE_UNUSED.

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

◆ 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 56 of file NESubTensorHandle.cpp.

References ARM_COMPUTE_UNUSED.

57 {
58  ARM_COMPUTE_UNUSED(blocking);
59 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ operator=() [1/2]

NESubTensorHandle& operator= ( NESubTensorHandle &&  )
default

Allow instances of this class to be moved.

◆ operator=() [2/2]

NESubTensorHandle& operator= ( const NESubTensorHandle )
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 81 of file NESubTensorHandle.cpp.

References ARM_COMPUTE_ERROR_ON, and ITensorHandle::parent_handle().

Referenced by NESubTensorHandle::NESubTensorHandle().

82 {
83  ARM_COMPUTE_ERROR_ON(_parent_handle == nullptr);
84  return _parent_handle->parent_handle();
85 }
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

◆ 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 66 of file NESubTensorHandle.cpp.

67 {
68  // noop
69 }

◆ target()

Target target ( ) const
overridevirtual

Returns target type.

Returns
Target type

Implements ITensorHandle.

Definition at line 92 of file NESubTensorHandle.cpp.

References arm_compute::graph::NEON.

93 {
94  return Target::NEON;
95 }
Arm® Neon™ capable target device.

◆ tensor() [1/2]

arm_compute::ITensor & tensor ( )
overridevirtual

Backend tensor object accessor.

Implements ITensorHandle.

Definition at line 76 of file NESubTensorHandle.cpp.

77 {
78  return _sub_tensor;
79 }

◆ tensor() [2/2]

const arm_compute::ITensor & tensor ( ) const
overridevirtual

Backend tensor object const accessor.

Implements ITensorHandle.

Definition at line 71 of file NESubTensorHandle.cpp.

72 {
73  return _sub_tensor;
74 }

◆ unmap()

void unmap ( )
overridevirtual

Un-maps a backend tensor object.

Implements ITensorHandle.

Definition at line 61 of file NESubTensorHandle.cpp.

62 {
63  // noop
64 }

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