Compute Library
 21.05
OperatorTensor Class Reference

Basic implementation of the tensor interface. More...

#include <OperatorTensor.h>

Collaboration diagram for OperatorTensor:
[legend]

Public Member Functions

 OperatorTensor (ITensorInfo *info, IMemory *memory)
 Constructor. More...
 
 ~OperatorTensor ()=default
 Destructor: free the tensor's memory. More...
 
 OperatorTensor (OperatorTensor &&)=default
 Allow instances of this class to be move constructed. More...
 
OperatorTensoroperator= (OperatorTensor &&)=default
 Allow instances of this class to be moved. More...
 
OperatorTensoroperator= (const OperatorTensor &)=delete
 Prevent instances of this class to be copy assigned. More...
 
 OperatorTensor (const OperatorTensor &)=delete
 Prevent instances of this class to be copy constructed. More...
 
arm_compute::ITensorInfoinfo () const override
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
arm_compute::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...
 

Detailed Description

Basic implementation of the tensor interface.

Definition at line 42 of file OperatorTensor.h.

Constructor & Destructor Documentation

◆ OperatorTensor() [1/3]

OperatorTensor ( ITensorInfo info,
IMemory memory 
)

Constructor.

Parameters
[in]infoPointer to the tensor info.
[in]memoryPointer to the memory info.

Definition at line 33 of file OperatorTensor.cpp.

34  : _info(info), _memory(memory), _mem_type(MemoryType::CPU)
35 {
36 }
arm_compute::ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.

◆ ~OperatorTensor()

~OperatorTensor ( )
default

Destructor: free the tensor's memory.

◆ OperatorTensor() [2/3]

OperatorTensor ( OperatorTensor &&  )
default

Allow instances of this class to be move constructed.

◆ OperatorTensor() [3/3]

OperatorTensor ( const OperatorTensor )
delete

Prevent instances of this class to be copy 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 48 of file OperatorTensor.cpp.

49 {
50  switch(_mem_type)
51  {
52  case MemoryType::CPU:
53  return (uint8_t *)utils::cast::polymorphic_downcast<MemoryRegion *>(_memory->region())->buffer();
54  default:
55  ARM_COMPUTE_ERROR("Memory type not supported.");
56  }
57 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
virtual IMemoryRegion * region()=0
Region accessor.
uint8_t * buffer() const override
Interface to be implemented by the child class to return a pointer to CPU memory.

References ARM_COMPUTE_ERROR, arm_compute::experimental::CPU, and IMemory::region().

◆ 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 38 of file OperatorTensor.cpp.

39 {
40  return _info;
41 }

◆ 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 43 of file OperatorTensor.cpp.

44 {
45  return _info;
46 }

◆ operator=() [1/2]

OperatorTensor& operator= ( OperatorTensor &&  )
default

Allow instances of this class to be moved.

◆ operator=() [2/2]

OperatorTensor& operator= ( const OperatorTensor )
delete

Prevent instances of this class to be copy assigned.


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