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 42 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 45 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 47 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 129 of file AclTensorBuilder.h.

131 : _operands{operands}, _tensor_mgr{tensor_mgr}
132{
133 assert(_tensor_mgr);
134}

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

68{ 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 178 of file AclTensorBuilder.h.

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

295{
296 for (const auto &cand : seq)
297 {
298 if (!isSubTensorOf(parent, cand))
299 {
300 return false;
301 }
302 }
303 return true;
304}
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 165 of file AclTensorBuilder.h.

167{
168 return _tensor_info_map.find(ind) != _tensor_info_map.end();
169}

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

309{
310 auto itr = _parent_map.find(child);
311 if (itr == _parent_map.end())
312 {
313 return false;
314 }
315
316 return itr->second.parent == parent;
317}

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

154{
155 _lifetime_seq.emplace_back(UsesType::FIRST, ind);
156}

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

160{
161 _lifetime_seq.emplace_back(UsesType::LAST, ind);
162}

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

78 {
79 _parent_map = std::move(parent_map);
80 }
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 205 of file AclTensorBuilder.h.

206{
207 _tensor_mgr->tryDeallocConstants();
208}

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

173{
174 buildTensors();
175}

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

139{
140 assert(_tensor_mgr->constTensors().size() == 0);
141 assert(_tensor_mgr->nonconstTensors().size() == 0);
142
143 _uses_count_map[ind] = _operands.at(ind).getUses().size();
144
145 // SubTensors
146 assert((_parent_map.count(ind) == 0 || !info.isConstant()) &&
147 "Subtensors of constants are not supported yet.");
148
149 _tensor_info_map.emplace(ind, info);
150}
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 70 of file AclTensorBuilder.h.

71 {
72 assert(_uses_count_map.find(index) != _uses_count_map.end() ? _uses_count_map[index] == num_uses
73 : true);
74 _uses_count_map[index] = num_uses;
75 }
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

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