Compute Library
 21.11
SubTensor Class Reference

Basic implementation of the sub-tensor interface. More...

#include <SubTensor.h>

Collaboration diagram for SubTensor:
[legend]

Public Member Functions

 SubTensor ()
 Default Constructor. More...
 
 SubTensor (ITensor *parent, const TensorShape &tensor_shape, const Coordinates &coords, bool extend_parent=false)
 Constructor. More...
 
 ~SubTensor ()=default
 Destructor: free the tensor's memory. More...
 
 SubTensor (const SubTensor &)=delete
 Restrict instances of this class to be copy constructed. More...
 
SubTensoroperator= (const SubTensor &)=delete
 Restrict instances of this class to be copied. More...
 
 SubTensor (SubTensor &&)=default
 Allow instances of this class to be move constructed. More...
 
SubTensoroperator= (SubTensor &&)=default
 Allow instances of this class to be moved. More...
 
ITensorparent ()
 Return the parent tensor of the subtensor. More...
 
ITensorInfoinfo () const override
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
ITensorInfoinfo () override
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
uint8_t * buffer () const override
 Interface to be implemented by the child class to return a pointer to CPU memory. More...
 
- Public Member Functions inherited from ITensor
virtual ~ITensor ()=default
 Default virtual destructor. More...
 
uint8_t * ptr_to_element (const Coordinates &id) const
 Return a pointer to the element at the passed coordinates. More...
 
void copy_from (const ITensor &src)
 Copy the content of another tensor. More...
 
void print (std::ostream &s, IOFormatInfo io_fmt=IOFormatInfo()) const
 Print a tensor to a given stream using user defined formatting information. More...
 
bool is_used () const
 Flags if the tensor is used or not. More...
 
void mark_as_unused () const
 Marks a tensor as unused. More...
 
void mark_as_used () const
 Marks a tensor as used. More...
 

Detailed Description

Basic implementation of the sub-tensor interface.

Definition at line 37 of file SubTensor.h.

Constructor & Destructor Documentation

◆ SubTensor() [1/4]

SubTensor ( )

Default Constructor.

Definition at line 30 of file SubTensor.cpp.

31  : _parent(nullptr), _info()
32 {
33 }

◆ SubTensor() [2/4]

SubTensor ( ITensor parent,
const TensorShape tensor_shape,
const Coordinates coords,
bool  extend_parent = false 
)

Constructor.

Parameters
[in]parentParent tensor
[in]tensor_shapeShape of the subtensor
[in]coordsCoordinates of the first subtensor element inside the parent tensor.
[in]extend_parent(Optional) Extend parent with subtensor shape if subtensor indexes out of bounds

Definition at line 35 of file SubTensor.cpp.

References ARM_COMPUTE_ERROR_ON, ITensor::info(), and SubTensor::parent().

36  : _parent(nullptr), _info()
37 {
38  ARM_COMPUTE_ERROR_ON(parent == nullptr);
39  _info = SubTensorInfo(parent->info(), tensor_shape, coords, extend_parent);
40  _parent = parent;
41 }
#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
Store the sub tensor&#39;s metadata.
Definition: SubTensorInfo.h:41
ITensor * parent()
Return the parent tensor of the subtensor.
Definition: SubTensor.cpp:59
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.

◆ ~SubTensor()

~SubTensor ( )
default

Destructor: free the tensor's memory.

◆ SubTensor() [3/4]

SubTensor ( const SubTensor )
delete

Restrict instances of this class to be copy constructed.

◆ SubTensor() [4/4]

SubTensor ( SubTensor &&  )
default

Allow instances of this class to be move constructed.

Member Function Documentation

◆ buffer()

uint8_t * buffer ( ) const
overridevirtual

Interface to be implemented by the child class to return a pointer to CPU memory.

Returns
A CPU pointer to the beginning of the image's allocation.

Implements ITensor.

Definition at line 53 of file SubTensor.cpp.

References ARM_COMPUTE_ERROR_ON, and ITensor::buffer().

54 {
55  ARM_COMPUTE_ERROR_ON(_parent == nullptr);
56  return _parent->buffer();
57 }
#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
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...

◆ info() [1/2]

ITensorInfo * info ( ) const
overridevirtual

Interface to be implemented by the child class to return the tensor's metadata.

Returns
A pointer to the tensor's metadata.

Implements ITensor.

Definition at line 43 of file SubTensor.cpp.

44 {
45  return &_info;
46 }

◆ info() [2/2]

ITensorInfo * info ( )
overridevirtual

Interface to be implemented by the child class to return the tensor's metadata.

Returns
A pointer to the tensor's metadata.

Implements ITensor.

Definition at line 48 of file SubTensor.cpp.

49 {
50  return &_info;
51 }

◆ operator=() [1/2]

SubTensor& operator= ( const SubTensor )
delete

Restrict instances of this class to be copied.

◆ operator=() [2/2]

SubTensor& operator= ( SubTensor &&  )
default

Allow instances of this class to be moved.

◆ parent()

ITensor * parent ( )

Return the parent tensor of the subtensor.

Returns
Parent tensor

Definition at line 59 of file SubTensor.cpp.

Referenced by SubTensor::SubTensor().

60 {
61  return _parent;
62 }

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