ONE - On-device Neural Engine
Loading...
Searching...
No Matches
luci::RemoveDuplicateConstPass Struct Referencefinal

Class to remove duplicate Const nodes. More...

#include <RemoveDuplicateConstPass.h>

Collaboration diagram for luci::RemoveDuplicateConstPass:

Public Member Functions

const char * name (void) const final
 
bool run (loco::Graph *g) final
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Detailed Description

Class to remove duplicate Const nodes.

Definition at line 29 of file RemoveDuplicateConstPass.h.

Member Function Documentation

◆ name()

const char * luci::RemoveDuplicateConstPass::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 31 of file RemoveDuplicateConstPass.h.

31{ return "luci::RemoveDuplicateConstPass"; }

◆ run()

bool luci::RemoveDuplicateConstPass::run ( loco::Graph g)
finalvirtual

Remove duplicate Const nodes.

BEFORE [CircleNode] [CircleConst] | / | / [CircleNode] [CircleConst] | / | / [CircleNode]

AFTER

[CircleNode] [CircleConst] | / / | / / [CircleNode] / | / | / [CircleNode]

Implements logo::Pass.

Definition at line 198 of file RemoveDuplicateConstPass.cpp.

199{
200 for (auto node : loco::active_nodes(loco::output_nodes(g)))
201 {
202 auto const_node = dynamic_cast<luci::CircleConst *>(node);
203 if (const_node == nullptr)
204 continue;
205
206 switch (const_node->dtype())
207 {
208 case loco::DataType::FLOAT32:
209 add_to_map<loco::DataType::FLOAT32>(const_node);
210 break;
211 case loco::DataType::S32:
212 add_to_map<loco::DataType::S32>(const_node);
213 break;
214 case loco::DataType::S16:
215 add_to_map<loco::DataType::S16>(const_node);
216 break;
217 case loco::DataType::S8:
218 add_to_map<loco::DataType::S8>(const_node);
219 break;
220 case loco::DataType::S4:
221 add_to_map<loco::DataType::S4>(const_node);
222 break;
223 case loco::DataType::U8:
224 add_to_map<loco::DataType::U8>(const_node);
225 break;
226 case loco::DataType::U4:
227 add_to_map<loco::DataType::U4>(const_node);
228 break;
229 default:
230 continue;
231 }
232 }
233
234 return remove_duplicate_const();
235}
Class to build tensor data.
Definition CircleConst.h:35
std::set< loco::Node * > active_nodes(const std::vector< loco::Node * > &roots)
Enumerate all the nodes required to compute "roots".
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101

References loco::active_nodes(), and loco::output_nodes().

Referenced by package.infer.session::inference().


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