ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 119 of file AclTensorBuilder.h.

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

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 64 of file AclTensorBuilder.h.

64{ 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 168 of file AclTensorBuilder.h.

169{
170 auto lifetime_map = cl_common::createLifetimeMap(_lifetime_seq, _parent_map);
171
172 for (const auto &entry : lifetime_map)
173 {
174 const auto &[use_type, use_index] = entry.second;
175 assert(use_index.valid());
176 if (use_type == UsesType::FIRST)
177 _tensor_mgr->startLifetime(use_index);
178 else
179 _tensor_mgr->finishLifetime(use_index);
180 }
181
182 _tensor_mgr->allocateConsts();
183
184 // TODO Since `_parent_map` is filled for all Concat nodes even if the node this backend uses
185 // After refactoring BackendContext we can uncomment this
186 // assert(_tensor_info_map.size() ==
187 // _tensor_mgr->nonconstTensors().size() + num of constants of _tensor_info_map +
188 // _parent_map.size());
189 _tensor_mgr->allocateNonconsts();
190
191 _tensor_mgr->allocateInternalBufferManager();
192}
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 283 of file AclTensorBuilder.h.

285{
286 for (const auto &cand : seq)
287 {
288 if (!isSubTensorOf(parent, cand))
289 {
290 return false;
291 }
292 }
293 return true;
294}
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 155 of file AclTensorBuilder.h.

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

◆ 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 297 of file AclTensorBuilder.h.

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

◆ 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 143 of file AclTensorBuilder.h.

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

◆ 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 149 of file AclTensorBuilder.h.

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

◆ 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 73 of file AclTensorBuilder.h.

74 {
75 _parent_map = std::move(parent_map);
76 }
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 195 of file AclTensorBuilder.h.

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

◆ 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 162 of file AclTensorBuilder.h.

163{
164 buildTensors();
165}

◆ 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
[in]layoutTensor data layout

Definition at line 127 of file AclTensorBuilder.h.

129{
130 assert(_tensor_mgr->constTensors().size() == 0);
131 assert(_tensor_mgr->nonconstTensors().size() == 0);
132
133 _uses_count_map[ind] = _operands.at(ind).getUses().size();
134
135 // SubTensors
136 assert((_parent_map.count(ind) == 0 || !info.isConstant()) &&
137 "Subtensors of constants are not supported yet.");
138
139 _tensor_info_map.emplace(ind, info);
140}
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 66 of file AclTensorBuilder.h.

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

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