ONE - On-device Neural Engine
|
#include <Tensor.h>
Public Member Functions | |
Tensor ()=delete | |
virtual | ~Tensor () |
Tensor (const ir::OperandInfo &info, DynamicMemoryManager *dynamic_mem_mgr) | |
void | setBuffer (uint8_t *buffer) |
Set the Buffer object. This method is called for static and non-const tensor. | |
void | setBuffer (const std::shared_ptr< Allocator > &alloc) |
Set the Buffer object. This method is called for dynamic or const tensor. | |
void | deallocBuffer () override |
Reset the buffer and deallocate the allocation if it is managed by itself. | |
uint8_t * | buffer () const override |
void | set_dynamic () override |
set this tensor dynamic | |
bool | applyShape (const ir::Shape &new_shape) override |
Set the shape to shape and possibly re-allocate the buffer. | |
virtual void | increase_ref () |
virtual void | decrease_ref () |
virtual void | reset_ref () |
Reset reference count to zero and release data. | |
virtual int32_t | num_references () |
void | setShape (const ir::Shape &new_shape) override |
Set the shape of tenser to new_shape. | |
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 bool | is_subtensor () const |
virtual bool | needMemoryMap () const |
virtual void | enqueueWriteBuffer (const void *, bool) |
virtual void | enqueueReadBuffer (void *, bool) |
Protected Attributes | |
uint8_t * | _buffer |
size_t | _size |
int32_t | _num_references |
DynamicMemoryManager * | _dynamic_mem_mgr |
Protected Attributes inherited from onert::backend::IPortableTensor | |
ir::OperandInfo | _info |
|
delete |
|
inline |
Definition at line 43 of file Tensor.h.
|
overridevirtual |
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.
Reimplemented in onert::backend::train::Tensor.
Definition at line 33 of file Tensor.cc.
References _buffer, _dynamic_mem_mgr, onert::backend::IPortableTensor::_info, _size, onert::backend::basic::DynamicMemoryManager::allocate(), onert::backend::basic::DynamicMemoryManager::deallocate(), set_dynamic(), setBuffer(), onert::ir::OperandInfo::shape(), and onert::ir::OperandInfo::total_size().
|
inlineoverridevirtual |
Implements onert::backend::ITensor.
Definition at line 73 of file Tensor.h.
References _buffer.
Referenced by onert::backend::basic::train::TrainableTensor::buffer(), onert::backend::basic::train::TrainableTensor::fillBuffer(), and setBuffer().
|
overridevirtual |
Reset the buffer and deallocate the allocation if it is managed by itself.
Reimplemented from onert::backend::ITensor.
Definition at line 55 of file Tensor.cc.
References _buffer, _dynamic_mem_mgr, and onert::backend::basic::DynamicMemoryManager::deallocate().
|
inlinevirtual |
Reimplemented in onert::backend::basic::ExternalTensor.
Definition at line 86 of file Tensor.h.
References _buffer, and _num_references.
|
inlinevirtual |
Reimplemented in onert::backend::basic::ExternalTensor.
Definition at line 77 of file Tensor.h.
References _buffer, _num_references, and onert::backend::IPortableTensor::is_dynamic().
|
inlinevirtual |
Reimplemented in onert::backend::basic::ExternalTensor.
Definition at line 123 of file Tensor.h.
References _num_references.
|
inlinevirtual |
Reset reference count to zero and release data.
Reimplemented in onert::backend::basic::ExternalTensor.
Definition at line 107 of file Tensor.h.
References _buffer, and _num_references.
|
inlineoverridevirtual |
set this tensor dynamic
Reimplemented from onert::backend::ITensor.
Definition at line 74 of file Tensor.h.
References onert::backend::IPortableTensor::_info, and onert::ir::OperandInfo::setDynamic().
Referenced by applyShape().
|
inline |
|
inline |
Set the Buffer object. This method is called for static and non-const tensor.
Definition at line 56 of file Tensor.h.
References _buffer, and buffer().
Referenced by applyShape(), and onert::backend::basic::train::TrainableTensor::setBuffer().
|
overridevirtual |
Set the shape of tenser to new_shape.
Reimplemented from onert::backend::ITensor.
Definition at line 31 of file Tensor.cc.
References onert::backend::IPortableTensor::_info, and onert::ir::OperandInfo::shape().
|
protected |
Definition at line 128 of file Tensor.h.
Referenced by applyShape(), buffer(), onert::backend::basic::ExternalTensor::buffer(), deallocBuffer(), decrease_ref(), onert::backend::basic::ExternalTensor::decrease_ref(), increase_ref(), reset_ref(), onert::backend::basic::ExternalTensor::reset_ref(), setBuffer(), setBuffer(), and onert::backend::basic::ExternalTensor::setData().
|
protected |
Definition at line 131 of file Tensor.h.
Referenced by applyShape(), and deallocBuffer().
|
protected |
Definition at line 130 of file Tensor.h.
Referenced by decrease_ref(), onert::backend::basic::ExternalTensor::decrease_ref(), increase_ref(), onert::backend::basic::ExternalTensor::increase_ref(), num_references(), onert::backend::basic::ExternalTensor::num_references(), reset_ref(), and onert::backend::basic::ExternalTensor::reset_ref().
|
protected |
Definition at line 129 of file Tensor.h.
Referenced by applyShape().