ONE - On-device Neural Engine
|
Tensor object that indirects to the tensor it is pointing to. More...
#include <IOTensor.h>
Public Member Functions | |
IOTensor (const ir::OperandInfo &info) | |
~IOTensor () | |
void | setTensor (IPortableTensor *tensor) |
uint8_t * | buffer () const override |
ir::Layout | layout () const |
void | set_dynamic () override |
set this tensor dynamic | |
void | setShape (const ir::Shape &shape) override |
Set the shape of tenser to new_shape. | |
bool | applyShape (const ir::Shape &shape) override |
Set the shape to shape and possibly re-allocate the buffer. | |
Public Member Functions inherited from onert::backend::IPortableTensor | |
IPortableTensor (const ir::OperandInfo &info) | |
virtual | ~IPortableTensor () |
const ir::OperandInfo & | get_info () const |
const ir::Sparsity * | sparsity () const |
size_t | total_size () const override final |
size_t | calcOffset (const ir::Coordinates &coords) const override final |
ir::DataType | data_type () const override final |
float | data_scale () const override final |
int32_t | data_zero_point () const override final |
const std::vector< float > & | data_scales () const override final |
const std::vector< int32_t > & | data_zero_points () const override |
bool | is_constant () const override final |
Return true if the tensor is constant. | |
bool | is_dynamic () const override final |
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. | |
ir::Shape | getShape () const override final |
Get ir::Shape of tensor. | |
bool | has_padding () const final |
void | access (const std::function< void(ITensor &tensor)> &fn) final |
Public Member Functions inherited from onert::backend::ITensor | |
virtual | ~ITensor () |
virtual void | deallocBuffer () |
Dealloc the buffer (only for dynamic tensors) | |
virtual bool | is_subtensor () const |
virtual bool | needMemoryMap () const |
virtual void | enqueueWriteBuffer (const void *, bool) |
virtual void | enqueueReadBuffer (void *, bool) |
Additional Inherited Members | |
Protected Attributes inherited from onert::backend::IPortableTensor | |
ir::OperandInfo | _info |
Tensor object that indirects to the tensor it is pointing to.
A executor's I/O tensor could be two types.
UserTensor
, if it is the primary graph (package's input/output)IPortableTensor
from another executor, otherwiseTo support these, this object indirects everything to the actual tensor pointer.
IOTensor is derived from IPortableTensor, and it also have "_info" field. "_info" field is accessed by IPortableTensor's getter method.
It assumes that IOTensor's info is always same with actual tensor's info except shape. setTensor() updates IOTensor's info's shape to actual tensor shape. Actual tensor's info should not be updated directly after setTensor() call until executor's execution is finished, instead it is allowed to update actual tensor's info indirectly by IOTensor's setter methods.
Definition at line 49 of file IOTensor.h.
onert::backend::builtin::IOTensor::IOTensor | ( | const ir::OperandInfo & | info | ) |
Definition at line 32 of file IOTensor.cc.
onert::backend::builtin::IOTensor::~IOTensor | ( | ) |
Definition at line 30 of file IOTensor.cc.
|
inlineoverridevirtual |
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
shape | tensor's new shape. While allocating memory for this new_shape, tensor's shape is set to new_shape |
Reimplemented from onert::backend::ITensor.
Definition at line 91 of file IOTensor.h.
References onert::backend::IPortableTensor::_info, onert::backend::ITensor::applyShape(), onert::ir::OperandInfo::setDynamic(), and onert::ir::OperandInfo::shape().
|
inlineoverridevirtual |
Implements onert::backend::ITensor.
Definition at line 59 of file IOTensor.h.
References onert::backend::ITensor::buffer().
|
inline |
Definition at line 60 of file IOTensor.h.
|
inlineoverridevirtual |
set this tensor dynamic
Reimplemented from onert::backend::ITensor.
Definition at line 61 of file IOTensor.h.
References onert::backend::IPortableTensor::_info, onert::backend::ITensor::set_dynamic(), and onert::ir::OperandInfo::setDynamic().
|
inlineoverridevirtual |
Set the shape of tenser to new_shape.
Reimplemented from onert::backend::ITensor.
Definition at line 66 of file IOTensor.h.
References onert::backend::IPortableTensor::_info, onert::backend::ITensor::setShape(), and onert::ir::OperandInfo::shape().
void onert::backend::builtin::IOTensor::setTensor | ( | IPortableTensor * | tensor | ) |
Definition at line 39 of file IOTensor.cc.
References onert::backend::IPortableTensor::_info, onert::ir::OperandInfo::setDynamic(), and onert::ir::OperandInfo::shape().