Compute Library
 22.08
ClKernelFusionGroup Struct Reference

A const view of a subgraph of the ClKernelGraph to be fused together. More...

#include <ClFusedKernelGraph.h>

Collaboration diagram for ClKernelFusionGroup:
[legend]

Public Types

using Id = DependencyGraph::Id
 

Public Member Functions

 ClKernelFusionGroup ()=default
 
 ClKernelFusionGroup (Id id)
 
 ~ClKernelFusionGroup ()=default
 
void set_id (Id i)
 
Id add_fused_kernel (const ClKernel *kernel)
 
const ClKernelget_root_kernel () const
 
std::vector< const ClKernelTensor * > get_src_tensors () const
 
std::vector< const ClKernelTensor * > get_dst_tensors () const
 

Data Fields

Id id {}
 
DependencyGraph graph {}
 
std::map< Id, const ClKernel * > fused_kernels {}
 
std::map< Id, const ClKernelTensor * > tensors {}
 

Friends

bool operator== (const ClKernelFusionGroup &fg0, const ClKernelFusionGroup &fg1)
 

Detailed Description

A const view of a subgraph of the ClKernelGraph to be fused together.

Definition at line 47 of file ClFusedKernelGraph.h.

Member Typedef Documentation

◆ Id

Definition at line 50 of file ClFusedKernelGraph.h.

Constructor & Destructor Documentation

◆ ClKernelFusionGroup() [1/2]

ClKernelFusionGroup ( )
default

◆ ClKernelFusionGroup() [2/2]

◆ ~ClKernelFusionGroup()

Member Function Documentation

◆ add_fused_kernel()

Id add_fused_kernel ( const ClKernel kernel)
inline

PRE: Acyclicity ensured by DependencyGraph PRE: Connectedness ensured by DependencyGraph PRE: Single-rootedness ensured by User

Definition at line 64 of file ClFusedKernelGraph.h.

References DependencyGraph::add_operator(), DependencyGraph::add_tensor(), ClKernelFusionGroup::fused_kernels, ClKernelFusionGroup::graph, ClKernelFusionGroup::id, tf_frozen_model_extractor::t, ClKernel::tensors(), and ClKernelFusionGroup::tensors.

65  {
66  /// PRE: Acyclicity ensured by DependencyGraph
67  /// PRE: Connectedness ensured by DependencyGraph
68  /// PRE: Single-rootedness ensured by User
69  std::vector<Id> src_tensors;
70  for(const auto t : kernel->tensors().get_const_src_tensors())
71  {
72  auto id = graph.add_tensor(t->id);
73  if(tensors.find(id) == tensors.end())
74  {
75  tensors[id] = t;
76  }
77  src_tensors.push_back(id);
78  }
79  std::vector<Id> dst_tensors;
80  for(const auto t : kernel->tensors().get_const_dst_tensors())
81  {
82  auto id = graph.add_tensor(t->id);
83  if(tensors.find(id) == tensors.end())
84  {
85  tensors[id] = t;
86  }
87  dst_tensors.push_back(id);
88  }
89  auto id = graph.add_operator(src_tensors, dst_tensors);
90  fused_kernels[id.second] = kernel;
91  return id.second;
92  }
Id add_tensor(Id merge_tensor=empty_id())
Add a new tensor.
std::pair< Status, DependencyGraph::Id > add_operator(const std::vector< Id > &inputs, const std::vector< Id > &outputs)
Add a new operator.

◆ get_dst_tensors()

std::vector<const ClKernelTensor *> get_dst_tensors ( ) const
inline

Definition at line 111 of file ClFusedKernelGraph.h.

References DependencyGraph::dst_tensors(), ClKernelFusionGroup::graph, and ClKernelFusionGroup::tensors.

112  {
113  std::vector<const ClKernelTensor *> dst_tensors;
114  for(auto tensor_id : graph.dst_tensors())
115  {
116  dst_tensors.push_back(tensors.at(tensor_id));
117  }
118  return dst_tensors;
119  }
std::vector< Id > dst_tensors(Id op) const
Get destination tensors to an operator.

◆ get_root_kernel()

const ClKernel* get_root_kernel ( ) const
inline

Definition at line 94 of file ClFusedKernelGraph.h.

References ARM_COMPUTE_ERROR_ON, ClKernelFusionGroup::fused_kernels, DependencyGraph::get_root_ops(), and ClKernelFusionGroup::graph.

Referenced by arm_compute::experimental::dynamic_fusion::generate_store().

95  {
96  auto root_kernels = graph.get_root_ops();
97  ARM_COMPUTE_ERROR_ON(root_kernels.size() != 1);
98  return fused_kernels.at(root_kernels.at(0));
99  }
std::vector< Id > get_root_ops() const
Get all root ops.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ get_src_tensors()

std::vector<const ClKernelTensor *> get_src_tensors ( ) const
inline

Definition at line 101 of file ClFusedKernelGraph.h.

References ClKernelFusionGroup::graph, DependencyGraph::src_tensors(), and ClKernelFusionGroup::tensors.

102  {
103  std::vector<const ClKernelTensor *> src_tensors;
104  for(auto tensor_id : graph.src_tensors())
105  {
106  src_tensors.push_back(tensors.at(tensor_id));
107  }
108  return src_tensors;
109  }
std::vector< Id > src_tensors(Id op) const
Get source tensors to an operator.

◆ set_id()

void set_id ( Id  i)
inline

Definition at line 59 of file ClFusedKernelGraph.h.

60  {
61  id = i;
62  }

Friends And Related Function Documentation

◆ operator==

bool operator== ( const ClKernelFusionGroup fg0,
const ClKernelFusionGroup fg1 
)
friend

Definition at line 121 of file ClFusedKernelGraph.h.

122  {
123  return fg0.id == fg1.id && fg0.graph == fg1.graph && fg0.fused_kernels == fg1.fused_kernels && fg0.tensors == fg1.tensors;
124  }

Field Documentation

◆ fused_kernels

◆ graph

◆ id

◆ tensors


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