Compute Library
 22.08
ITensorDescPack< TDesc > Class Template Reference

#include <ITensorDescPack.h>

Data Structures

struct  PackElement
 

Public Member Functions

 ITensorDescPack ()=default
 Default Constructor. More...
 
 ~ITensorDescPack ()=default
 
 ITensorDescPack (const ITensorDescPack< TDesc > &other)=default
 
ITensorDescPack< TDesc > & operator= (const ITensorDescPack< TDesc > &other)=default
 
 ITensorDescPack (ITensorDescPack< TDesc > &&other)=default
 
ITensorDescPack< TDesc > & operator= (ITensorDescPack< TDesc > &&other)=default
 
 ITensorDescPack (std::initializer_list< PackElement > l)
 Initializer list Constructor. More...
 
void add_tensor (int id, TDesc *tensor)
 Add tensor to the pack. More...
 
void add_const_tensor (int id, const TDesc *tensor)
 Add const tensor to the pack. More...
 
TDesc * get_tensor (int id)
 Get tensor of a given id from the pac. More...
 
const TDesc * get_const_tensor (int id) const
 Get constant tensor of a given id. More...
 
void remove_tensor (int id)
 Remove the tensor stored with the given id. More...
 
size_t size () const
 Pack size accessor. More...
 
bool empty () const
 Checks if pack is empty. More...
 
std::vector< TDesc * > get_src_tensors ()
 Get the ACL_SRC_* tensors. More...
 
std::vector< const TDesc * > get_const_src_tensors () const
 Get the const ACL_SRC_* tensors. More...
 
std::vector< TDesc * > get_dst_tensors ()
 Get the ACL_DST_* tensors. More...
 
std::vector< const TDesc * > get_const_dst_tensors () const
 Get the const ACL_DST_* tensors. More...
 

Friends

bool operator== (const ITensorDescPack< TDesc > &pack0, const ITensorDescPack< TDesc > &pack1)
 

Detailed Description

template<typename TDesc>
class arm_compute::experimental::dynamic_fusion::ITensorDescPack< TDesc >

Definition at line 39 of file ITensorDescPack.h.

Constructor & Destructor Documentation

◆ ITensorDescPack() [1/4]

ITensorDescPack ( )
default

Default Constructor.

◆ ~ITensorDescPack()

~ITensorDescPack ( )
default

◆ ITensorDescPack() [2/4]

ITensorDescPack ( const ITensorDescPack< TDesc > &  other)
default

◆ ITensorDescPack() [3/4]

ITensorDescPack ( ITensorDescPack< TDesc > &&  other)
default

◆ ITensorDescPack() [4/4]

ITensorDescPack ( std::initializer_list< PackElement l)
inline

Initializer list Constructor.

Definition at line 81 of file ITensorDescPack.h.

82  : _pack{}
83  {
84  for(auto &e : l)
85  {
86  _pack[e.id] = e;
87  }
88  }

Member Function Documentation

◆ add_const_tensor()

void add_const_tensor ( int  id,
const TDesc *  tensor 
)
inline

Add const tensor to the pack.

Parameters
[in]idID/type of the tensor to add
[in]tensorTensor to add

Definition at line 104 of file ITensorDescPack.h.

Referenced by arm_compute::experimental::dynamic_fusion::add_op_conv2d(), arm_compute::experimental::dynamic_fusion::add_op_elementwise_op(), arm_compute::experimental::dynamic_fusion::add_op_floor(), Conv2dContent::translate(), ElementwiseContent::translate(), and FloorContent::translate().

105  {
106  _pack[id] = PackElement(id, tensor);
107  }

◆ add_tensor()

void add_tensor ( int  id,
TDesc *  tensor 
)
inline

Add tensor to the pack.

Parameters
[in]idID/type of the tensor to add
[in]tensorTensor to add

Definition at line 94 of file ITensorDescPack.h.

95  {
96  _pack[id] = PackElement(id, tensor);
97  }

◆ empty()

bool empty ( ) const
inline

Checks if pack is empty.

Returns
True if empty else false

Definition at line 154 of file ITensorDescPack.h.

155  {
156  return _pack.empty();
157  }

◆ get_const_dst_tensors()

std::vector<const TDesc *> get_const_dst_tensors ( ) const
inline

Get the const ACL_DST_* tensors.

Returns
std::vector<const TDesc *>

Definition at line 214 of file ITensorDescPack.h.

Referenced by ClKernelGraph::add_kernel().

215  {
216  std::vector<const TDesc *> dst_tensors{};
217  for(int id = static_cast<int>(TensorType::ACL_DST); id <= static_cast<int>(TensorType::ACL_DST_END); ++id)
218  {
219  auto tensor = get_const_tensor(id);
220  if(tensor != nullptr)
221  {
222  dst_tensors.push_back(tensor);
223  }
224  }
225  return dst_tensors;
226  }
const TDesc * get_const_tensor(int id) const
Get constant tensor of a given id.

◆ get_const_src_tensors()

std::vector<const TDesc *> get_const_src_tensors ( ) const
inline

Get the const ACL_SRC_* tensors.

Returns
std::vector<const TDesc *>

Definition at line 180 of file ITensorDescPack.h.

Referenced by ClKernelGraph::add_kernel().

181  {
182  std::vector<const TDesc *> src_tensors{};
183  for(int id = static_cast<int>(TensorType::ACL_SRC); id <= static_cast<int>(TensorType::ACL_SRC_END); ++id)
184  {
185  auto tensor = get_const_tensor(id);
186  if(tensor != nullptr)
187  {
188  src_tensors.push_back(tensor);
189  }
190  }
191  return src_tensors;
192  }
const TDesc * get_const_tensor(int id) const
Get constant tensor of a given id.

◆ get_const_tensor()

const TDesc* get_const_tensor ( int  id) const
inline

Get constant tensor of a given id.

Parameters
[in]idID of tensor to extract
Returns
The pointer to the tensor if exist and is const else nullptr

Definition at line 125 of file ITensorDescPack.h.

Referenced by ITensorDescPack< arm_compute::experimental::dynamic_fusion::OpTensorContent >::get_const_dst_tensors(), and ITensorDescPack< arm_compute::experimental::dynamic_fusion::OpTensorContent >::get_const_src_tensors().

126  {
127  auto it = _pack.find(id);
128  if(it != _pack.end())
129  {
130  return it->second.ctensor != nullptr ? it->second.ctensor : it->second.tensor;
131  }
132  return nullptr;
133  }

◆ get_dst_tensors()

std::vector<TDesc *> get_dst_tensors ( )
inline

Get the ACL_DST_* tensors.

Returns
std::vector<TDesc *>

Definition at line 197 of file ITensorDescPack.h.

198  {
199  std::vector<TDesc *> dst_tensors{};
200  for(int id = static_cast<int>(TensorType::ACL_DST); id <= static_cast<int>(TensorType::ACL_DST_END); ++id)
201  {
202  auto tensor = get_tensor(id);
203  if(tensor != nullptr)
204  {
205  dst_tensors.push_back(tensor);
206  }
207  }
208  return dst_tensors;
209  }
TDesc * get_tensor(int id)
Get tensor of a given id from the pac.

◆ get_src_tensors()

std::vector<TDesc *> get_src_tensors ( )
inline

Get the ACL_SRC_* tensors.

Returns
std::vector<TDesc *>

Definition at line 163 of file ITensorDescPack.h.

164  {
165  std::vector<TDesc *> src_tensors{};
166  for(int id = static_cast<int>(TensorType::ACL_SRC); id <= static_cast<int>(TensorType::ACL_SRC_END); ++id)
167  {
168  auto tensor = get_tensor(id);
169  if(tensor != nullptr)
170  {
171  src_tensors.push_back(tensor);
172  }
173  }
174  return src_tensors;
175  }
TDesc * get_tensor(int id)
Get tensor of a given id from the pac.

◆ get_tensor()

TDesc* get_tensor ( int  id)
inline

Get tensor of a given id from the pac.

Parameters
[in]idID of tensor to extract
Returns
The pointer to the tensor if exist and is non-const else nullptr

Definition at line 114 of file ITensorDescPack.h.

Referenced by ITensorDescPack< arm_compute::experimental::dynamic_fusion::OpTensorContent >::get_dst_tensors(), and ITensorDescPack< arm_compute::experimental::dynamic_fusion::OpTensorContent >::get_src_tensors().

115  {
116  auto it = _pack.find(id);
117  return it != _pack.end() ? it->second.tensor : nullptr;
118  }

◆ operator=() [1/2]

ITensorDescPack<TDesc>& operator= ( const ITensorDescPack< TDesc > &  other)
default

◆ operator=() [2/2]

ITensorDescPack<TDesc>& operator= ( ITensorDescPack< TDesc > &&  other)
default

◆ remove_tensor()

void remove_tensor ( int  id)
inline

Remove the tensor stored with the given id.

Parameters
[in]idID of tensor to remove

Definition at line 138 of file ITensorDescPack.h.

139  {
140  _pack.erase(id);
141  }

◆ size()

size_t size ( ) const
inline

Pack size accessor.

Returns
Number of tensors registered to the pack

Definition at line 146 of file ITensorDescPack.h.

147  {
148  return _pack.size();
149  }

Friends And Related Function Documentation

◆ operator==

bool operator== ( const ITensorDescPack< TDesc > &  pack0,
const ITensorDescPack< TDesc > &  pack1 
)
friend

Definition at line 228 of file ITensorDescPack.h.

229  {
230  return pack0._pack == pack1._pack;
231  }

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