ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
onert::backend::builtin::TensorBuilder Class Reference

#include <TensorBuilder.h>

Public Member Functions

 TensorBuilder (const std::shared_ptr< TensorRegistry > &tensor_reg)
 
void registerTensorInfo (const ir::OperandIndex &ind, const ir::OperandInfo &info)
 Register tensor information to allocate on CPU backend.
 
void notifyFirstUse (const ir::OperandIndex &)
 
void notifyLastUse (const ir::OperandIndex &)
 
bool isRegistered (const ir::OperandIndex &) const
 
void allocate (void)
 
DynamicTensorManagerdynamicTensorManager (void)
 
basic::TensornativeOwnTensorAt (const ir::OperandIndex &ind)
 Get tensor with a specific OperandIndex.
 

Detailed Description

Definition at line 33 of file TensorBuilder.h.

Constructor & Destructor Documentation

◆ TensorBuilder()

onert::backend::builtin::TensorBuilder::TensorBuilder ( const std::shared_ptr< TensorRegistry > &  tensor_reg)

Definition at line 26 of file TensorBuilder.cc.

27 : _tensor_reg{tensor_reg}, _dynamic_tensor_mgr{new DynamicTensorManager(_tensor_reg->base_reg())},
28 _static_tensor_mgr{new basic::StaticTensorManager(
29 _tensor_reg->base_reg(), _dynamic_tensor_mgr.get(), ir::OperandIndexMap<ir::OperandIndex>{})}
30{
31 /* empty */
32}
basic::DynamicTensorManager DynamicTensorManager

Member Function Documentation

◆ allocate()

void onert::backend::builtin::TensorBuilder::allocate ( void  )

Definition at line 86 of file TensorBuilder.cc.

86{ _static_tensor_mgr->allocateNonconsts(); }

◆ dynamicTensorManager()

DynamicTensorManager * onert::backend::builtin::TensorBuilder::dynamicTensorManager ( void  )

Definition at line 88 of file TensorBuilder.cc.

89{
90 return _dynamic_tensor_mgr.get();
91}

◆ isRegistered()

bool onert::backend::builtin::TensorBuilder::isRegistered ( const ir::OperandIndex ind) const

Definition at line 76 of file TensorBuilder.cc.

77{
78 // User tensors are not registered in _tensor_info_map but objects for them are exist
79 // in the tensor registry.
80 // TODO Enhance the way of checking user tensors
81 if (_tensor_reg->getITensor(ind))
82 return true;
83 return _tensor_info_map.find(ind) != _tensor_info_map.end();
84}

◆ nativeOwnTensorAt()

basic::Tensor * onert::backend::builtin::TensorBuilder::nativeOwnTensorAt ( const ir::OperandIndex ind)

Get tensor with a specific OperandIndex.

Parameters
indOperandIndex for the tensor. There must exist a tensor with this ind. If not, program will crash with assert or exception.
Returns
operand::Tensor *

Definition at line 93 of file TensorBuilder.cc.

94{
95 return _tensor_reg->getNativeOwnTensor(ind);
96}

◆ notifyFirstUse()

void onert::backend::builtin::TensorBuilder::notifyFirstUse ( const ir::OperandIndex ind)

Definition at line 49 of file TensorBuilder.cc.

50{
51 // TODO Enhance the way of checking user tensors
52 if (_tensor_info_map.find(ind) == _tensor_info_map.end()) // Do not proceed for user tensors
53 return;
54
55 const auto &tensor_info = _tensor_info_map.at(ind);
56
57 if (!nativeOwnTensorAt(ind)->is_dynamic())
58 {
59 const auto size = tensor_info.total_size();
60 _static_tensor_mgr->claimPlan(ind, size);
61 }
62}
basic::Tensor * nativeOwnTensorAt(const ir::OperandIndex &ind)
Get tensor with a specific OperandIndex.
int32_t size[5]
Definition Slice.cpp:35

References size.

◆ notifyLastUse()

void onert::backend::builtin::TensorBuilder::notifyLastUse ( const ir::OperandIndex ind)

Definition at line 64 of file TensorBuilder.cc.

65{
66 // TODO Enhance the way of checking user tensors
67 if (_tensor_info_map.find(ind) == _tensor_info_map.end()) // Do not proceed for user tensors
68 return;
69
70 if (!nativeOwnTensorAt(ind)->is_dynamic())
71 {
72 _static_tensor_mgr->releasePlan(ind);
73 }
74}

◆ registerTensorInfo()

void onert::backend::builtin::TensorBuilder::registerTensorInfo ( const ir::OperandIndex ind,
const ir::OperandInfo info 
)

Register tensor information to allocate on CPU backend.

Parameters
[in]indOperand index
[in]infoOperand information

Definition at line 34 of file TensorBuilder.cc.

35{
36 _tensor_info_map.emplace(ind, info);
37
38 VERBOSE_F() << "cpucommon REGISTER!! " << ind << std::endl;
39 if (info.isDynamic())
40 {
41 _dynamic_tensor_mgr->buildTensor(ind, info);
42 }
43 else
44 {
45 _static_tensor_mgr->buildTensor(ind, info, info.isConstant());
46 }
47}
volatile const char info[]
#define VERBOSE_F()
Definition logging.h:69

References info, and VERBOSE_F.


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