Compute Library
 22.05
ITensorV2 Class Referenceabstract

Base class specifying the tensor interface. More...

#include <ITensorV2.h>

Collaboration diagram for ITensorV2:
[legend]

Public Member Functions

 ITensorV2 (IContext *ctx)
 Explict Operator Constructor. More...
 
virtual ~ITensorV2 ()
 Destructor. More...
 
bool is_valid () const
 Checks if a queue is valid. More...
 
virtual void * map ()=0
 Map tensor to a host pointer. More...
 
virtual StatusCode unmap ()=0
 Unmap tensor. More...
 
virtual StatusCode import (void *handle, ImportMemoryType type)=0
 Import external memory handle. More...
 
virtual arm_compute::ITensortensor () const =0
 Get the legacy tensor object. More...
 
size_t get_size () const
 Get the size of the tensor in byte. More...
 
AclTensorDescriptor get_descriptor () const
 Get the descriptor of this tensor. More...
 

Additional Inherited Members

- Data Fields inherited from AclTensor_
arm_compute::detail::Header header { arm_compute::detail::ObjectType::Tensor, nullptr }
 

Detailed Description

Base class specifying the tensor interface.

Definition at line 45 of file ITensorV2.h.

Constructor & Destructor Documentation

◆ ITensorV2()

ITensorV2 ( IContext ctx)
inlineexplicit

Explict Operator Constructor.

Parameters
[in]ctxContext to be used by the operator

Definition at line 52 of file ITensorV2.h.

References ARM_COMPUTE_ASSERT_NOT_NULLPTR, Header::ctx, AclTensor_::header, and IContext::inc_ref().

53  : AclTensor_()
54  {
56  this->header.ctx = ctx;
57  this->header.ctx->inc_ref();
58  }
arm_compute::detail::Header header
Definition: ITensorV2.h:32
void inc_ref() const
Increment context refcount.
Definition: IContext.h:71
#define ARM_COMPUTE_ASSERT_NOT_NULLPTR(ptr)
Definition: Validate.h:38

◆ ~ITensorV2()

virtual ~ITensorV2 ( )
inlinevirtual

Destructor.

Definition at line 60 of file ITensorV2.h.

References Header::ctx, IContext::dec_ref(), AclTensor_::header, and Header::type.

61  {
62  this->header.ctx->dec_ref();
64  };
arm_compute::detail::Header header
Definition: ITensorV2.h:32
void dec_ref() const
Decrement context refcount.
Definition: IContext.h:76

Member Function Documentation

◆ get_descriptor()

AclTensorDescriptor get_descriptor ( ) const

Get the descriptor of this tensor.

Returns
The descriptor describing the characteristics of this tensor

Definition at line 35 of file ITensorV2.cpp.

References arm_compute::detail::convert_to_descriptor(), arm_compute::test::validation::info, and ITensorV2::tensor().

36 {
38 }
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
AclTensorDescriptor convert_to_descriptor(const TensorInfo &info)
Convert a legacy tensor meta-data to a descriptor.
virtual arm_compute::ITensor * tensor() const =0
Get the legacy tensor object.

◆ get_size()

size_t get_size ( ) const

Get the size of the tensor in byte.

Note
The size isn't based on allocated memory, but based on information in its descriptor (dimensions, data type, etc.).
Returns
The size of the tensor in byte

Definition at line 30 of file ITensorV2.cpp.

References ITensor::info(), ITensorV2::tensor(), and ITensorInfo::total_size().

31 {
32  return tensor()->info()->total_size();
33 }
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
virtual arm_compute::ITensor * tensor() const =0
Get the legacy tensor object.

◆ import()

virtual StatusCode import ( void *  handle,
ImportMemoryType  type 
)
pure virtual

Import external memory handle.

Parameters
[in]handleMemory to import
[in]typeType of imported memory
Returns
Status code

Implemented in ClTensor, and CpuTensor.

◆ is_valid()

bool is_valid ( ) const
inline

Checks if a queue is valid.

Returns
True if successful otherwise false

Definition at line 69 of file ITensorV2.h.

References AclTensor_::header, arm_compute::utils::map(), Header::type, type, and arm_compute::utils::unmap().

Referenced by arm_compute::detail::validate_internal_tensor().

70  {
71  return this->header.type == detail::ObjectType::Tensor;
72  };
arm_compute::detail::Header header
Definition: ITensorV2.h:32

◆ map()

virtual void* map ( )
pure virtual

Map tensor to a host pointer.

Returns
A pointer to the underlying backing memory if successful else nullptr

Implemented in ClTensor, and CpuTensor.

◆ tensor()

virtual arm_compute::ITensor* tensor ( ) const
pure virtual

Get the legacy tensor object.

Returns
The legacy underlying tensor object

Implemented in ClTensor, and CpuTensor.

Referenced by AclGetClMem(), TensorPack::add_tensor(), ITensorV2::get_descriptor(), and ITensorV2::get_size().

◆ unmap()

virtual StatusCode unmap ( )
pure virtual

Unmap tensor.

Returns
AclStatus A status cod

Implemented in ClTensor, and CpuTensor.


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