ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor > Class Template Reference

#include <AclTensorBuilder.h>

Public Types

using T_AclTensorManager = AclTensorManager< T_ITensor, T_Tensor, T_SubTensor >
 
using UsesType = cl_common::UsesType
 

Public Member Functions

 AclTensorBuilder (const ir::Operands &operands, T_AclTensorManager *tensor_mgr)
 
void registerTensorInfo (const ir::OperandIndex &ind, const ir::OperandInfo &info)
 Register tensor information to allocate on ACL-CL backend.
 
void notifyFirstUse (const ir::OperandIndex &)
 
void notifyLastUse (const ir::OperandIndex &)
 
bool isRegistered (const ir::OperandIndex &) const
 
void prepare (void)
 
void allocate ()
 
void postFunctionPrepare ()
 
T_AclTensorManageracl_tensor_manager (void)
 
void setUsesCount (const ir::OperandIndex &index, size_t num_uses)
 
void parent_map (std::unordered_map< ir::OperandIndex, cl_common::ParentInfo > &&parent_map)
 
bool areSubTensorsOf (const ir::OperandIndex &parent, const ir::OperandIndexSequence &seq)
 
bool isSubTensorOf (const ir::OperandIndex &parent, const ir::OperandIndex &child)
 Check child tensor is allocated as subtensor of parent tensor.
 

Detailed Description

template<typename T_ITensor, typename T_Tensor, typename T_SubTensor>
class onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >

Definition at line 38 of file AclTensorBuilder.h.

Member Typedef Documentation

◆ T_AclTensorManager

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
using onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::T_AclTensorManager = AclTensorManager<T_ITensor, T_Tensor, T_SubTensor>

Definition at line 41 of file AclTensorBuilder.h.

◆ UsesType

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
using onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::UsesType = cl_common::UsesType

Definition at line 43 of file AclTensorBuilder.h.

Constructor & Destructor Documentation

◆ AclTensorBuilder()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::AclTensorBuilder ( const ir::Operands operands,
T_AclTensorManager tensor_mgr 
)

Definition at line 118 of file AclTensorBuilder.h.

120 : _operands{operands}, _tensor_mgr{tensor_mgr}
121{
122 assert(_tensor_mgr);
123}

Member Function Documentation

◆ acl_tensor_manager()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
T_AclTensorManager * onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::acl_tensor_manager ( void  )
inline

Definition at line 63 of file AclTensorBuilder.h.

63{ return _tensor_mgr.get(); }

◆ allocate()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::allocate ( void  )

Definition at line 167 of file AclTensorBuilder.h.

168{
169 auto lifetime_map = cl_common::createLifetimeMap(_lifetime_seq, _parent_map);
170
171 for (const auto &entry : lifetime_map)
172 {
173 const auto &[use_type, use_index] = entry.second;
174 assert(use_index.valid());
175 if (use_type == UsesType::FIRST)
176 _tensor_mgr->startLifetime(use_index);
177 else
178 _tensor_mgr->finishLifetime(use_index);
179 }
180
181 _tensor_mgr->allocateConsts();
182
183 // TODO Since `_parent_map` is filled for all Concat nodes even if the node this backend uses
184 // After refactoring BackendContext we can uncomment this
185 // assert(_tensor_info_map.size() ==
186 // _tensor_mgr->nonconstTensors().size() + num of constants of _tensor_info_map +
187 // _parent_map.size());
188 _tensor_mgr->allocateNonconsts();
189
190 _tensor_mgr->allocateInternalBufferManager();
191}
int entry(const int argc, char **argv)
Definition Driver.cpp:53
LifetimeMap createLifetimeMap(LifetimeSeq &seq, ir::OperandIndexMap< ParentInfo > &parent_map)

References onert::backend::cl_common::createLifetimeMap(), and entry().

◆ areSubTensorsOf()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
bool onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::areSubTensorsOf ( const ir::OperandIndex parent,
const ir::OperandIndexSequence seq 
)

Definition at line 282 of file AclTensorBuilder.h.

284{
285 for (const auto &cand : seq)
286 {
287 if (!isSubTensorOf(parent, cand))
288 {
289 return false;
290 }
291 }
292 return true;
293}
bool isSubTensorOf(const ir::OperandIndex &parent, const ir::OperandIndex &child)
Check child tensor is allocated as subtensor of parent tensor.

◆ isRegistered()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
bool onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::isRegistered ( const ir::OperandIndex ind) const

Definition at line 154 of file AclTensorBuilder.h.

156{
157 return _tensor_info_map.find(ind) != _tensor_info_map.end();
158}

◆ isSubTensorOf()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
bool onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::isSubTensorOf ( const ir::OperandIndex parent,
const ir::OperandIndex child 
)

Check child tensor is allocated as subtensor of parent tensor.

Parameters
[in]parentIndex of parent
[in]childIndex of child
Returns
true if child is allocated as subtensor of parent, otherwise false

Definition at line 296 of file AclTensorBuilder.h.

298{
299 auto itr = _parent_map.find(child);
300 if (itr == _parent_map.end())
301 {
302 return false;
303 }
304
305 return itr->second.parent == parent;
306}

◆ notifyFirstUse()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::notifyFirstUse ( const ir::OperandIndex ind)

Definition at line 142 of file AclTensorBuilder.h.

143{
144 _lifetime_seq.emplace_back(UsesType::FIRST, ind);
145}

◆ notifyLastUse()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::notifyLastUse ( const ir::OperandIndex ind)

Definition at line 148 of file AclTensorBuilder.h.

149{
150 _lifetime_seq.emplace_back(UsesType::LAST, ind);
151}

◆ parent_map()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::parent_map ( std::unordered_map< ir::OperandIndex, cl_common::ParentInfo > &&  parent_map)
inline

Definition at line 72 of file AclTensorBuilder.h.

73 {
74 _parent_map = std::move(parent_map);
75 }
void parent_map(std::unordered_map< ir::OperandIndex, cl_common::ParentInfo > &&parent_map)

References onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::parent_map().

Referenced by onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::parent_map().

◆ postFunctionPrepare()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::postFunctionPrepare ( void  )

Definition at line 194 of file AclTensorBuilder.h.

195{
196 _tensor_mgr->tryDeallocConstants();
197}

◆ prepare()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::prepare ( void  )

Definition at line 161 of file AclTensorBuilder.h.

162{
163 buildTensors();
164}

◆ registerTensorInfo()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::registerTensorInfo ( const ir::OperandIndex ind,
const ir::OperandInfo info 
)

Register tensor information to allocate on ACL-CL backend.

Parameters
[in]indOperand index
[in]infoTensor information

Definition at line 126 of file AclTensorBuilder.h.

128{
129 assert(_tensor_mgr->constTensors().size() == 0);
130 assert(_tensor_mgr->nonconstTensors().size() == 0);
131
132 _uses_count_map[ind] = _operands.at(ind).getUses().size();
133
134 // SubTensors
135 assert((_parent_map.count(ind) == 0 || !info.isConstant()) &&
136 "Subtensors of constants are not supported yet.");
137
138 _tensor_info_map.emplace(ind, info);
139}
const Object & at(const Index &index) const
Get the object that is associated with the given index.
volatile const char info[]

References info.

◆ setUsesCount()

template<typename T_ITensor , typename T_Tensor , typename T_SubTensor >
void onert::backend::acl_common::AclTensorBuilder< T_ITensor, T_Tensor, T_SubTensor >::setUsesCount ( const ir::OperandIndex index,
size_t  num_uses 
)
inline

Definition at line 65 of file AclTensorBuilder.h.

66 {
67 assert(_uses_count_map.find(index) != _uses_count_map.end() ? _uses_count_map[index] == num_uses
68 : true);
69 _uses_count_map[index] = num_uses;
70 }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

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