ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::ITensor Class Referenceabstract

#include <ITensor.h>

Public Member Functions

virtual ~ITensor ()
 
virtual uint8_t * buffer () const =0
 
virtual size_t total_size () const =0
 
virtual size_t calcOffset (const ir::Coordinates &coords) const =0
 
virtual ir::DataType data_type () const =0
 
virtual float data_scale () const =0
 
virtual int32_t data_zero_point () const =0
 
virtual const std::vector< float > & data_scales () const =0
 
virtual const std::vector< int32_t > & data_zero_points () const =0
 
virtual bool has_padding () const =0
 
virtual void access (const std::function< void(ITensor &tensor)> &fn)=0
 
virtual bool applyShape (const ir::Shape &)
 Set the shape to shape and possibly re-allocate the buffer.
 
virtual bool is_constant () const
 Return true if the tensor is constant.
 
virtual bool is_dynamic () const =0
 Return true if the tensor needs dynamic allocation, meaning that during compile-time the outpus shape cannot be known and the output shape is calculated during kernel execution-time.
 
virtual void set_dynamic ()
 set this tensor dynamic
 
virtual void deallocBuffer ()
 Dealloc the buffer (only for dynamic tensors)
 
virtual void setShape (const ir::Shape &)
 Set the shape of tenser to new_shape.
 
virtual ir::Shape getShape () const =0
 Get ir::Shape of tensor.
 
virtual bool is_subtensor () const
 
virtual bool needMemoryMap () const
 
virtual void enqueueWriteBuffer (const void *, bool)
 
virtual void enqueueReadBuffer (void *, bool)
 

Detailed Description

Definition at line 35 of file ITensor.h.

Constructor & Destructor Documentation

◆ ~ITensor()

onert::backend::ITensor::~ITensor ( )
virtual

Definition at line 26 of file ITensor.cc.

26{}

Member Function Documentation

◆ access()

virtual void onert::backend::ITensor::access ( const std::function< void(ITensor &tensor)> &  fn)
pure virtual

◆ applyShape()

virtual bool onert::backend::ITensor::applyShape ( const ir::Shape )
inlinevirtual

Set the shape to shape and possibly re-allocate the buffer.

If a tensor is dynamic tensor and previously allocated memory exists, it will be deallocated. If a tensor is static tensor (with previously allocated memory by StaticTensorManager), buffer() will be overwriten

Parameters
shapetensor's new shape. While allocating memory for this new_shape, tensor's shape is set to new_shape
Returns
true If applying shape is successful
false If not applying shape is not supported (it throws for other errors)

Reimplemented in onert::backend::train::Tensor, onert::backend::builtin::UserTensor, onert::backend::basic::Tensor, onert::exec::EdgeTensor, and onert::backend::builtin::IOTensor.

Definition at line 65 of file ITensor.h.

65{ return false; }

Referenced by onert::backend::builtin::IOTensor::applyShape(), and onert::backend::builtin::kernel::PermuteLayer::run().

◆ buffer()

virtual uint8_t * onert::backend::ITensor::buffer ( ) const
pure virtual

◆ calcOffset()

virtual size_t onert::backend::ITensor::calcOffset ( const ir::Coordinates coords) const
pure virtual

◆ data_scale()

virtual float onert::backend::ITensor::data_scale ( ) const
pure virtual

◆ data_scales()

virtual const std::vector< float > & onert::backend::ITensor::data_scales ( ) const
pure virtual

◆ data_type()

virtual ir::DataType onert::backend::ITensor::data_type ( ) const
pure virtual

◆ data_zero_point()

virtual int32_t onert::backend::ITensor::data_zero_point ( ) const
pure virtual

◆ data_zero_points()

virtual const std::vector< int32_t > & onert::backend::ITensor::data_zero_points ( ) const
pure virtual

◆ deallocBuffer()

virtual void onert::backend::ITensor::deallocBuffer ( )
inlinevirtual

Dealloc the buffer (only for dynamic tensors)

Reimplemented in onert::backend::basic::Tensor.

Definition at line 89 of file ITensor.h.

90 {
91 throw std::runtime_error("This backend does not support resetting buffer");
92 }

◆ enqueueReadBuffer()

virtual void onert::backend::ITensor::enqueueReadBuffer ( void *  ,
bool   
)
inlinevirtual

Reimplemented in onert::backend::acl_cl::operand::ICLTensor.

Definition at line 115 of file ITensor.h.

116 {
117 throw std::runtime_error("This backend does not support enqueueReadBuffer");
118 }

◆ enqueueWriteBuffer()

virtual void onert::backend::ITensor::enqueueWriteBuffer ( const void *  ,
bool   
)
inlinevirtual

Reimplemented in onert::backend::acl_cl::operand::ICLTensor.

Definition at line 111 of file ITensor.h.

112 {
113 throw std::runtime_error("This backend does not support enqueueWriteBuffer");
114 }

◆ getShape()

virtual ir::Shape onert::backend::ITensor::getShape ( ) const
pure virtual

Get ir::Shape of tensor.

Note
Higer dimension will be placed on front.

Implemented in onert::backend::acl_common::IACLTensor, and onert::backend::IPortableTensor.

Referenced by onert::backend::builtin::kernel::PermuteLayer::run(), and onert::exec::DynamicShapeInferer::visit().

◆ has_padding()

◆ is_constant()

virtual bool onert::backend::ITensor::is_constant ( ) const
inlinevirtual

Return true if the tensor is constant.

Reimplemented in onert::backend::IPortableTensor.

Definition at line 70 of file ITensor.h.

71 {
72 throw std::runtime_error("This backend does not support checking constant");
73 }

◆ is_dynamic()

virtual bool onert::backend::ITensor::is_dynamic ( ) const
pure virtual

Return true if the tensor needs dynamic allocation, meaning that during compile-time the outpus shape cannot be known and the output shape is calculated during kernel execution-time.

Implemented in onert::backend::acl_common::IACLTensor, and onert::backend::IPortableTensor.

Referenced by onert::backend::builtin::kernel::PermuteLayer::run().

◆ is_subtensor()

virtual bool onert::backend::ITensor::is_subtensor ( ) const
inlinevirtual

Reimplemented in onert::backend::acl_cl::operand::CLSubTensor, and onert::backend::acl_neon::operand::NESubTensor.

Definition at line 109 of file ITensor.h.

109{ return false; }

◆ needMemoryMap()

virtual bool onert::backend::ITensor::needMemoryMap ( ) const
inlinevirtual

Reimplemented in onert::backend::acl_cl::operand::ICLTensor.

Definition at line 110 of file ITensor.h.

110{ return false; }

◆ set_dynamic()

virtual void onert::backend::ITensor::set_dynamic ( )
inlinevirtual

set this tensor dynamic

Reimplemented in onert::backend::basic::Tensor, onert::backend::basic::ExternalTensor, onert::backend::builtin::IOTensor, onert::backend::builtin::UserTensor, and onert::exec::EdgeTensor.

Definition at line 83 of file ITensor.h.

84 {
85 throw std::runtime_error("This backend does not support dynamic tensor");
86 }

Referenced by onert::backend::builtin::IOTensor::set_dynamic().

◆ setShape()

virtual void onert::backend::ITensor::setShape ( const ir::Shape )
inlinevirtual

Set the shape of tenser to new_shape.

Note
Higer dimension will be placed on front.

Reimplemented in onert::backend::basic::ExternalTensor, onert::backend::basic::Tensor, onert::backend::builtin::UserTensor, onert::exec::EdgeTensor, and onert::backend::builtin::IOTensor.

Definition at line 98 of file ITensor.h.

99 {
100 throw std::runtime_error("This backend does not support dynamic setShape");
101 }

Referenced by onert::backend::builtin::IOTensor::setShape().

◆ total_size()

virtual size_t onert::backend::ITensor::total_size ( ) const
pure virtual

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