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

Tensor registry class for builtin backend. More...

#include <TensorRegistry.h>

Collaboration diagram for onert::backend::builtin::TensorRegistry:

Public Member Functions

 TensorRegistry ()
 
ITensorgetITensor (const ir::OperandIndex &ind) override
 Returns pointer of ITensor among native and migrant tensors.
 
ITensorgetNativeITensor (const ir::OperandIndex &ind) override
 Returns pointer of ITensor among native tensors.
 
IPortableTensorgetPortableTensor (const ir::OperandIndex &ind)
 
IPortableTensorgetNativeTensor (const ir::OperandIndex &ind)
 
TensorgetNativeOwnTensor (const ir::OperandIndex &ind)
 
IOTensorgetNativeIOTensor (const ir::OperandIndex &ind)
 
bool setMigrantTensor (const ir::OperandIndex &ind, IPortableTensor *tensor) override
 Set the Migrant Tensor which are from other backends.
 
void setNativeOwnTensor (ir::OperandIndex ind, std::unique_ptr< Tensor > &&tensor)
 
void setNativeIOTensor (ir::OperandIndex ind, std::unique_ptr< IOTensor > &&tensor)
 
const ir::OperandIndexMap< std::unique_ptr< IOTensor > > & native_io_tensors ()
 
std::shared_ptr< basic::TensorRegistrybase_reg ()
 
- Public Member Functions inherited from onert::backend::ITensorRegistry
virtual ~ITensorRegistry ()=default
 Deconstruct itself.
 

Detailed Description

Tensor registry class for builtin backend.

This class contains three types of tensors. Two native tensors(tensors that are managed by this backend) and the other is migrant tensor.

  • NativeIOTensor - IOTensor managed by this backend ( in _base_reg )
    • NOTE The tensor it actually points to can be from another backend
  • NativeOwnTensor - basic::Tensor managed by this backend ( in _base_reg )
  • MigrantTensor - IPortableTensor managed by other backends
Note
_base_reg is used in implementation to reuse basic::StaticTensorManager

Definition at line 47 of file TensorRegistry.h.

Constructor & Destructor Documentation

◆ TensorRegistry()

onert::backend::builtin::TensorRegistry::TensorRegistry ( )
inline

Definition at line 50 of file TensorRegistry.h.

50: _base_reg{new basic::TensorRegistry} {}
PortableTensorRegistryTemplate< basic::Tensor > TensorRegistry

Member Function Documentation

◆ base_reg()

std::shared_ptr< basic::TensorRegistry > onert::backend::builtin::TensorRegistry::base_reg ( )
inline

Definition at line 123 of file TensorRegistry.h.

123{ return _base_reg; }

◆ getITensor()

ITensor * onert::backend::builtin::TensorRegistry::getITensor ( const ir::OperandIndex )
inlineoverridevirtual

Returns pointer of ITensor among native and migrant tensors.

Native Tensor is a tensor that is managed by this backend Migrant Tensor is a tensor that is imported from another backend

Note
Return tensor cannot be used longer than dynamic tensor manager

Implements onert::backend::ITensorRegistry.

Definition at line 52 of file TensorRegistry.h.

53 {
54 auto base_tensor = _base_reg->getITensor(ind);
55 if (base_tensor)
56 return base_tensor;
57 return getNativeIOTensor(ind);
58 }
IOTensor * getNativeIOTensor(const ir::OperandIndex &ind)

References getNativeIOTensor().

Referenced by setMigrantTensor(), setNativeIOTensor(), and setNativeOwnTensor().

◆ getNativeIOTensor()

IOTensor * onert::backend::builtin::TensorRegistry::getNativeIOTensor ( const ir::OperandIndex ind)
inline

Definition at line 89 of file TensorRegistry.h.

90 {
91 auto tensor = _native_io_tensors.find(ind);
92 if (tensor != _native_io_tensors.end())
93 return tensor->second.get();
94 return nullptr;
95 }

Referenced by getITensor(), getNativeITensor(), getNativeTensor(), and getPortableTensor().

◆ getNativeITensor()

ITensor * onert::backend::builtin::TensorRegistry::getNativeITensor ( const ir::OperandIndex )
inlineoverridevirtual

Returns pointer of ITensor among native tensors.

Unlike getITensor , this function only searches from native tensors

Note
Returned tensor cannot be used longer than dynamic tensor manager

Implements onert::backend::ITensorRegistry.

Definition at line 60 of file TensorRegistry.h.

61 {
62 auto base_tensor = _base_reg->getNativeITensor(ind);
63 if (base_tensor)
64 return base_tensor;
65 return getNativeIOTensor(ind);
66 }

References getNativeIOTensor().

◆ getNativeOwnTensor()

Tensor * onert::backend::builtin::TensorRegistry::getNativeOwnTensor ( const ir::OperandIndex ind)
inline

Definition at line 84 of file TensorRegistry.h.

85 {
86 return _base_reg->getNativeTensor(ind);
87 }

◆ getNativeTensor()

IPortableTensor * onert::backend::builtin::TensorRegistry::getNativeTensor ( const ir::OperandIndex ind)
inline

Definition at line 76 of file TensorRegistry.h.

77 {
78 auto base_tensor = _base_reg->getNativeTensor(ind);
79 if (base_tensor)
80 return base_tensor;
81 return getNativeIOTensor(ind);
82 }

References getNativeIOTensor().

◆ getPortableTensor()

IPortableTensor * onert::backend::builtin::TensorRegistry::getPortableTensor ( const ir::OperandIndex ind)
inline

Definition at line 68 of file TensorRegistry.h.

69 {
70 auto base_tensor = _base_reg->getPortableTensor(ind);
71 if (base_tensor)
72 return base_tensor;
73 return getNativeIOTensor(ind);
74 }

References getNativeIOTensor().

◆ native_io_tensors()

const ir::OperandIndexMap< std::unique_ptr< IOTensor > > & onert::backend::builtin::TensorRegistry::native_io_tensors ( )
inline

Definition at line 119 of file TensorRegistry.h.

120 {
121 return _native_io_tensors;
122 }

◆ setMigrantTensor()

bool onert::backend::builtin::TensorRegistry::setMigrantTensor ( const ir::OperandIndex ,
IPortableTensor  
)
inlineoverridevirtual

Set the Migrant Tensor which are from other backends.

Returns
true if supported
false if not supported

Reimplemented from onert::backend::ITensorRegistry.

Definition at line 97 of file TensorRegistry.h.

98 {
99 assert(tensor);
100 assert(!getITensor(ind)); // For the ind, tensor is not registered yet
101 _base_reg->setMigrantTensor(ind, tensor);
102 return true;
103 }
ITensor * getITensor(const ir::OperandIndex &ind) override
Returns pointer of ITensor among native and migrant tensors.

References getITensor().

◆ setNativeIOTensor()

void onert::backend::builtin::TensorRegistry::setNativeIOTensor ( ir::OperandIndex  ind,
std::unique_ptr< IOTensor > &&  tensor 
)
inline

Definition at line 112 of file TensorRegistry.h.

113 {
114 assert(tensor);
115 assert(!getITensor(ind)); // For the ind, tensor is not registered yet
116 _native_io_tensors[ind] = std::move(tensor);
117 }

References getITensor().

◆ setNativeOwnTensor()

void onert::backend::builtin::TensorRegistry::setNativeOwnTensor ( ir::OperandIndex  ind,
std::unique_ptr< Tensor > &&  tensor 
)
inline

Definition at line 105 of file TensorRegistry.h.

106 {
107 assert(tensor);
108 assert(!getITensor(ind)); // For the ind, tensor is not registered yet
109 _base_reg->setNativeTensor(ind, std::move(tensor));
110 }

References getITensor().


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