Compute Library
 22.08
NETensorHandle Class Referencefinal

CPU Tensor handle interface object. More...

#include <NETensorHandle.h>

Collaboration diagram for NETensorHandle:
[legend]

Public Member Functions

 NETensorHandle (const ITensorInfo &info)
 Default Constructor. More...
 
 ~NETensorHandle ()=default
 Destructor: free the tensor's memory. More...
 
 NETensorHandle (NETensorHandle &&)=default
 Allow instances of this class to be move constructed. More...
 
NETensorHandleoperator= (NETensorHandle &&)=default
 Allow instances of this class to be moved. 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 Tensor handle interface object.

Definition at line 38 of file NETensorHandle.h.

Constructor & Destructor Documentation

◆ NETensorHandle() [1/2]

NETensorHandle ( const ITensorInfo info)

Default Constructor.

Parameters
[in]infoTensor metadata

Definition at line 35 of file NETensorHandle.cpp.

References Tensor::allocator(), and TensorAllocator::init().

36  : _tensor()
37 {
38  _tensor.allocator()->init(info);
39 }
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ ~NETensorHandle()

~NETensorHandle ( )
default

Destructor: free the tensor's memory.

◆ NETensorHandle() [2/2]

NETensorHandle ( NETensorHandle &&  )
default

Allow instances of this class to be move constructed.

Member Function Documentation

◆ allocate()

void allocate ( )
overridevirtual

Allocates backend memory for the handle.

Implements ITensorHandle.

Definition at line 41 of file NETensorHandle.cpp.

References TensorAllocator::allocate(), and Tensor::allocator().

42 {
43  _tensor.allocator()->allocate();
44 }
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void allocate() override
Allocate size specified by TensorInfo of CPU memory.

◆ free()

void free ( )
overridevirtual

Allocates backend memory for the handle.

Implements ITensorHandle.

Definition at line 46 of file NETensorHandle.cpp.

References Tensor::allocator(), and TensorAllocator::free().

47 {
48  _tensor.allocator()->free();
49 }
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void free() override
Free allocated CPU memory.

◆ 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 92 of file NETensorHandle.cpp.

93 {
94  return false;
95 }

◆ 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 51 of file NETensorHandle.cpp.

References IMemoryGroup::manage().

52 {
53  if(mg != nullptr)
54  {
55  mg->manage(&_tensor);
56  }
57 }

◆ 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 NETensorHandle.cpp.

References ARM_COMPUTE_UNUSED.

60 {
61  ARM_COMPUTE_UNUSED(blocking);
62 }
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152

◆ operator=()

NETensorHandle& operator= ( NETensorHandle &&  )
default

Allow instances of this class to be moved.

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

88 {
89  return this;
90 }

◆ 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 68 of file NETensorHandle.cpp.

References Tensor::allocator(), TensorAllocator::free(), and ITensor::is_used().

69 {
70  // TODO (geopin01): Release tensor only if all sub-tensors are marked as not used
71  if(!_tensor.is_used())
72  {
73  _tensor.allocator()->free();
74  }
75 }
bool is_used() const
Flags if the tensor is used or not.
Definition: ITensor.cpp:163
TensorAllocator * allocator()
Return a pointer to the tensor&#39;s allocator.
Definition: Tensor.cpp:48
void free() override
Free allocated CPU memory.

◆ target()

Target target ( ) const
overridevirtual

Returns target type.

Returns
Target type

Implements ITensorHandle.

Definition at line 97 of file NETensorHandle.cpp.

References arm_compute::graph::NEON.

98 {
99  return Target::NEON;
100 }
Arm® Neon™ capable target device.

◆ tensor() [1/2]

arm_compute::ITensor & tensor ( )
overridevirtual

Backend tensor object accessor.

Implements ITensorHandle.

Definition at line 82 of file NETensorHandle.cpp.

83 {
84  return _tensor;
85 }

◆ tensor() [2/2]

const arm_compute::ITensor & tensor ( ) const
overridevirtual

Backend tensor object const accessor.

Implements ITensorHandle.

Definition at line 77 of file NETensorHandle.cpp.

78 {
79  return _tensor;
80 }

◆ unmap()

void unmap ( )
overridevirtual

Un-maps a backend tensor object.

Implements ITensorHandle.

Definition at line 64 of file NETensorHandle.cpp.

65 {
66 }

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