ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::IPortableTensor Class Reference

A tensor class that is portable for other backends. More...

#include <IPortableTensor.h>

Collaboration diagram for onert::backend::IPortableTensor:

Public Member Functions

 IPortableTensor (const ir::OperandInfo &info)
 
virtual ~IPortableTensor ()
 
const ir::OperandInfoget_info () const
 
const ir::Sparsitysparsity () 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 uint8_t * buffer () const =0
 
virtual bool applyShape (const ir::Shape &)
 Set the shape to shape and possibly re-allocate the buffer.
 
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 bool is_subtensor () const
 
virtual bool needMemoryMap () const
 
virtual void enqueueWriteBuffer (const void *, bool)
 
virtual void enqueueReadBuffer (void *, bool)
 

Protected Attributes

ir::OperandInfo _info
 

Detailed Description

A tensor class that is portable for other backends.

Backends that use derivatives of this interface can reuse each other's tensors without copying. Here's criterion to be a portable tensor:

  • it must not have any paddings
  • No special operations on access method
    • e.g. CL memory must map/unmap to use it from CPU, the memory so it cannot be portable

Definition at line 38 of file IPortableTensor.h.

Constructor & Destructor Documentation

◆ IPortableTensor()

onert::backend::IPortableTensor::IPortableTensor ( const ir::OperandInfo info)
inline

Definition at line 41 of file IPortableTensor.h.

41: _info(info) {}
volatile const char info[]

◆ ~IPortableTensor()

onert::backend::IPortableTensor::~IPortableTensor ( )
virtual

Definition at line 26 of file IPortableTensor.cc.

26{}

Member Function Documentation

◆ access()

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

Implements onert::backend::ITensor.

Definition at line 70 of file IPortableTensor.h.

70{ fn(*this); }

◆ calcOffset()

size_t onert::backend::IPortableTensor::calcOffset ( const ir::Coordinates coords) const
finaloverridevirtual

Implements onert::backend::ITensor.

Definition at line 28 of file IPortableTensor.cc.

29{
30 auto shape = _info.shape();
31 size_t rank = shape.rank();
32 rank = rank == 0 ? 1 : rank;
33 size_t offset = 0;
34 for (size_t i = 0; i < rank; ++i)
35 {
36 auto dim = shape.rank() == 0 ? 1 : shape.dim(i);
37 offset = offset * dim + coords[i];
38 }
40 return offset;
41}
Array< CornerBox > coords
ir::DataType data_type() const override final
const Shape & shape() const
Return tensor shape.
Definition OperandInfo.h:95
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540
size_t sizeOfDataType(DataType data_type)
Definition DataType.cc:29

References _info, coords, data_type(), offset(), and onert::ir::OperandInfo::shape().

◆ data_scale()

◆ data_scales()

◆ data_type()

ir::DataType onert::backend::IPortableTensor::data_type ( ) const
inlinefinaloverridevirtual

Implements onert::backend::ITensor.

Definition at line 56 of file IPortableTensor.h.

56{ return _info.typeInfo().type(); }
DataType type() const
Definition TypeInfo.h:52

References _info, onert::ir::TypeInfo::type(), and onert::ir::OperandInfo::typeInfo().

Referenced by onert::backend::builtin::UserTensor::applyShape(), onert::exec::EdgeTensor::applyShape(), onert::backend::train::ops::BinaryArithmeticLayer::backward(), onert::backend::train::ops::ConvolutionLayer::backward(), onert::backend::train::ops::DepthwiseConvolutionLayer::backward(), onert::backend::train::ops::FullyConnectedLayer::backward(), onert::backend::train::ops::LossCategoricalCrossentropyLayer::backward(), onert::backend::train::ops::LossMeanSquaredErrorLayer::backward(), onert::backend::train::ops::MeanLayer::backward(), onert::backend::train::ops::PadLayer::backward(), onert::backend::train::ops::SoftMaxLayer::backward(), calcOffset(), onert::backend::cpu::ops::LogSoftMaxLayer::configure(), onert::backend::cpu::ops::SoftMaxLayer::configure(), onert::backend::cpu::ops::MeanLayer::configure(), onert::backend::cpu::ops::ReduceLayer::configure(), onert::backend::cpu::ops::GatherLayer::configure(), onert::backend::cpu::ops::DepthwiseConvolutionLayer::configure(), onert::backend::cpu::ops::ConvolutionLayer::configure(), onert::backend::cpu::ops::FullyConnectedLayer::configure(), onert::backend::cpu::ops::PoolLayer::configure(), onert::backend::cpu::ops::QuantizeLayer::configure(), onert::backend::cpu::ops::ElementwiseActivationLayer::configure(), onert::backend::cpu::ops::ElementwiseBinaryLayer::configure(), onert::backend::cpu::ops::BinaryArithmeticLayer::configure(), onert::backend::train::ops::DepthwiseConvolutionLayer::configureBackward(), onert::backend::train::ops::PadLayer::depad(), onert::backend::train::ops::LossCategoricalCrossentropyLayer::forward(), onert::backend::train::ops::LossMeanSquaredErrorLayer::forward(), onert::backend::cpu::ops::getReducerAxes(), onert::backend::cpu::ops::MatrixBandPartLayer::matrixBandPartFloat32(), onert::backend::cpu::ops::PadLayer::padImpl(), onert::backend::cpu::ops::ConvolutionLayer::prepare(), onert::backend::cpu::ops::FullyConnectedLayer::prepare(), onert::backend::ruy::ops::ConvolutionLayer::prepare(), onert::backend::cpu::ops::LogSoftMaxLayer::run(), onert::backend::cpu::ops::AddNLayer::run(), onert::backend::cpu::ops::ArgMinMaxLayer::run(), onert::backend::cpu::ops::BatchMatMulLayer::run(), onert::backend::cpu::ops::BatchToSpaceNDLayer::run(), onert::backend::cpu::ops::BroadcastToLayer::run(), onert::backend::cpu::ops::CompareLayer::run(), onert::backend::cpu::ops::ConcatLayer::run(), onert::backend::cpu::ops::ConvolutionLayer::run(), onert::backend::cpu::ops::DepthToSpaceLayer::run(), onert::backend::cpu::ops::DepthwiseConvolutionLayer::run(), onert::backend::cpu::ops::EinsumLayer::run(), onert::backend::cpu::ops::FillLayer::run(), onert::backend::cpu::ops::FullyConnectedLayer::run(), onert::backend::cpu::ops::FusedBatchNormLayer::run(), onert::backend::cpu::ops::GatherLayer::run(), onert::backend::cpu::ops::L2NormLayer::run(), onert::backend::cpu::ops::LSTMLayer::run(), onert::backend::cpu::ops::MatrixBandPartLayer::run(), onert::backend::cpu::ops::MeanLayer::run(), onert::backend::cpu::ops::OneHotLayer::run(), onert::backend::cpu::ops::PackLayer::run(), onert::backend::cpu::ops::PadLayer::run(), onert::backend::cpu::ops::PowLayer::run(), onert::backend::cpu::ops::QuantizeLayer::run(), onert::backend::cpu::ops::RangeLayer::run(), onert::backend::cpu::ops::ReduceLayer::run(), onert::backend::cpu::ops::ResizeBilinearLayer::run(), onert::backend::cpu::ops::ReverseLayer::run(), onert::backend::cpu::ops::RmsNormLayer::run(), onert::backend::cpu::ops::RoPELayer::run(), onert::backend::cpu::ops::SelectLayer::run(), onert::backend::cpu::ops::ShapeLayer::run(), onert::backend::cpu::ops::SliceLayer::run(), onert::backend::cpu::ops::SoftMaxLayer::run(), onert::backend::cpu::ops::SpaceToBatchNDLayer::run(), onert::backend::cpu::ops::SpaceToDepthLayer::run(), onert::backend::cpu::ops::SplitLayer::run(), onert::backend::cpu::ops::SplitVLayer::run(), onert::backend::cpu::ops::SqDiffLayer::run(), onert::backend::cpu::ops::StatelessRandomUniformLayer::run(), onert::backend::cpu::ops::StridedSliceLayer::run(), onert::backend::cpu::ops::TileLayer::run(), onert::backend::cpu::ops::TransposeLayer::run(), onert::backend::cpu::ops::UnpackLayer::run(), onert::backend::ruy::ops::ConvolutionLayer::run(), onert::backend::ruy::ops::FullyConnectedLayer::run(), onert::backend::xnnpack::ops::ConvolutionLayer::run(), onert::backend::xnnpack::ops::DepthwiseConvolutionLayer::run(), onert::backend::xnnpack::ops::FullyConnectedLayer::run(), onert::backend::cpu::ops::SplitLayer::split(), and onert::backend::cpu::ops::SplitVLayer::splitV().

◆ data_zero_point()

◆ data_zero_points()

const std::vector< int32_t > & onert::backend::IPortableTensor::data_zero_points ( ) const
inlineoverridevirtual

Implements onert::backend::ITensor.

Definition at line 60 of file IPortableTensor.h.

61 {
62 return _info.typeInfo().zero_points();
63 }
const std::vector< int32_t > & zero_points() const
Definition TypeInfo.h:60

References _info, onert::ir::OperandInfo::typeInfo(), and onert::ir::TypeInfo::zero_points().

Referenced by onert::backend::cpu::ops::DepthwiseConvolutionLayer::convQ8uPerChannel().

◆ get_info()

◆ getShape()

ir::Shape onert::backend::IPortableTensor::getShape ( ) const
inlinefinaloverridevirtual

◆ has_padding()

bool onert::backend::IPortableTensor::has_padding ( ) const
inlinefinalvirtual

Implements onert::backend::ITensor.

Definition at line 69 of file IPortableTensor.h.

69{ return false; }

◆ is_constant()

◆ is_dynamic()

bool onert::backend::IPortableTensor::is_dynamic ( ) const
inlinefinaloverridevirtual

◆ sparsity()

const ir::Sparsity * onert::backend::IPortableTensor::sparsity ( ) const
inline

◆ total_size()

Field Documentation

◆ _info


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