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

#include <TensorBuilder.h>

Public Member Functions

 TensorBuilder (const std::shared_ptr< TensorRegistry > &tensor_reg, const ir::OperandIndexMap< ir::OperandIndex > &shared_memory_operand_indexes={})
 
 TensorBuilder (const std::shared_ptr< TensorRegistry > &tensor_reg, const std::string planner_id, const ir::OperandIndexMap< ir::OperandIndex > &shared_memory_operand_indexes={})
 
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)
 
const ir::OperandIndexMap< ir::OperandIndex > & getSharedMemoryOperandIndexes () const
 
DynamicTensorManagerdynamicTensorManager (void)
 

Detailed Description

Definition at line 37 of file TensorBuilder.h.

Constructor & Destructor Documentation

◆ TensorBuilder() [1/2]

onert::backend::basic::TensorBuilder::TensorBuilder ( const std::shared_ptr< TensorRegistry > &  tensor_reg,
const ir::OperandIndexMap< ir::OperandIndex > &  shared_memory_operand_indexes = {} 
)

Definition at line 30 of file TensorBuilder.cc.

33 : _tensor_reg{tensor_reg}, _dynamic_tensor_mgr{new DynamicTensorManager(_tensor_reg)},
34 _static_tensor_mgr{new StaticTensorManager(_tensor_reg, _dynamic_tensor_mgr.get(),
35 shared_memory_operand_indexes)},
36 _shared_memory_operand_indexes{shared_memory_operand_indexes}
37{
38 /* empty */
39}
basic::DynamicTensorManager DynamicTensorManager
basic::StaticTensorManager StaticTensorManager

◆ TensorBuilder() [2/2]

onert::backend::basic::TensorBuilder::TensorBuilder ( const std::shared_ptr< TensorRegistry > &  tensor_reg,
const std::string  planner_id,
const ir::OperandIndexMap< ir::OperandIndex > &  shared_memory_operand_indexes = {} 
)

Definition at line 41 of file TensorBuilder.cc.

44 : _tensor_reg{tensor_reg}, _dynamic_tensor_mgr{new DynamicTensorManager(_tensor_reg)},
45 _static_tensor_mgr{new StaticTensorManager(_tensor_reg, planner_id, _dynamic_tensor_mgr.get(),
46 shared_memory_operand_indexes)}
47{
48 /* empty */
49}

Member Function Documentation

◆ allocate()

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

Definition at line 90 of file TensorBuilder.cc.

90{ _static_tensor_mgr->allocateNonconsts(); }

◆ dynamicTensorManager()

DynamicTensorManager * onert::backend::basic::TensorBuilder::dynamicTensorManager ( void  )
inline

Definition at line 61 of file TensorBuilder.h.

61{ return _dynamic_tensor_mgr.get(); }

◆ getSharedMemoryOperandIndexes()

const ir::OperandIndexMap< ir::OperandIndex > & onert::backend::basic::TensorBuilder::getSharedMemoryOperandIndexes ( ) const

Definition at line 92 of file TensorBuilder.cc.

93{
94 return _shared_memory_operand_indexes;
95}

◆ isRegistered()

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

Definition at line 85 of file TensorBuilder.cc.

86{
87 return _tensor_info_map.find(ind) != _tensor_info_map.end();
88}

◆ notifyFirstUse()

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

Definition at line 65 of file TensorBuilder.cc.

66{
67 assert(_tensor_info_map.find(ind) != _tensor_info_map.end());
68 const auto &tensor_info = _tensor_info_map.at(ind);
69
70 if (!_tensor_reg->getNativeTensor(ind)->is_dynamic())
71 {
72 const auto size = tensor_info.total_size();
73 _static_tensor_mgr->claimPlan(ind, size);
74 }
75}
int32_t size[5]
Definition Slice.cpp:35

References size.

◆ notifyLastUse()

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

Definition at line 77 of file TensorBuilder.cc.

78{
79 if (!_tensor_reg->getNativeTensor(ind)->is_dynamic())
80 {
81 _static_tensor_mgr->releasePlan(ind);
82 }
83}

◆ registerTensorInfo()

void onert::backend::basic::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 51 of file TensorBuilder.cc.

52{
53 _tensor_info_map.emplace(ind, info);
54
55 if (info.isDynamic())
56 {
57 _dynamic_tensor_mgr->buildTensor(ind, info);
58 }
59 else
60 {
61 _static_tensor_mgr->buildTensor(ind, info, info.isConstant());
62 }
63}
volatile const char info[]

References info.


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