ONE - On-device Neural Engine
Loading...
Searching...
No Matches
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 37 of file TensorBuilder.h.

Constructor & Destructor Documentation

◆ TensorBuilder()

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

Definition at line 30 of file TensorBuilder.cc.

31 : _tensor_reg{tensor_reg}, _dynamic_tensor_mgr{new DynamicTensorManager(_tensor_reg->base_reg())},
32 _static_tensor_mgr{new basic::StaticTensorManager(
33 _tensor_reg->base_reg(), _dynamic_tensor_mgr.get(), ir::OperandIndexMap<ir::OperandIndex>{})}
34{
35 /* empty */
36}
basic::DynamicTensorManager DynamicTensorManager

Member Function Documentation

◆ allocate()

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

Definition at line 90 of file TensorBuilder.cc.

90{ _static_tensor_mgr->allocateNonconsts(); }

◆ dynamicTensorManager()

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

Definition at line 92 of file TensorBuilder.cc.

93{
94 return _dynamic_tensor_mgr.get();
95}

◆ isRegistered()

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

Definition at line 80 of file TensorBuilder.cc.

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

◆ 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 97 of file TensorBuilder.cc.

98{
99 return _tensor_reg->getNativeOwnTensor(ind);
100}

◆ notifyFirstUse()

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

Definition at line 53 of file TensorBuilder.cc.

54{
55 // TODO Enhance the way of checking user tensors
56 if (_tensor_info_map.find(ind) == _tensor_info_map.end()) // Do not proceed for user tensors
57 return;
58
59 const auto &tensor_info = _tensor_info_map.at(ind);
60
61 if (!nativeOwnTensorAt(ind)->is_dynamic())
62 {
63 const auto size = tensor_info.total_size();
64 _static_tensor_mgr->claimPlan(ind, size);
65 }
66}
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 68 of file TensorBuilder.cc.

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

◆ 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 38 of file TensorBuilder.cc.

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

References info, and VERBOSE_F.


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