ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fme_apply::InsertScaleShift Class Reference

Class to insert scale/shift virtual Ops to loco::Graph. More...

#include <InsertScaleShift.h>

Public Member Functions

 InsertScaleShift (std::vector< EqualizePattern > &patterns)
 
void run (loco::Graph *graph)
 

Detailed Description

Class to insert scale/shift virtual Ops to loco::Graph.

Definition at line 30 of file InsertScaleShift.h.

Constructor & Destructor Documentation

◆ InsertScaleShift()

fme_apply::InsertScaleShift::InsertScaleShift ( std::vector< EqualizePattern > &  patterns)
inline

Definition at line 33 of file InsertScaleShift.h.

33 : _patterns{patterns}
34 {
35 // DO NOTHING
36 }

Member Function Documentation

◆ run()

void fme_apply::InsertScaleShift::run ( loco::Graph graph)

Definition at line 338 of file InsertScaleShift.cpp.

339{
340 // Create a map for pattern matching
341 // { back(string) -> EqualizationPattern*}
342 // This assumes that each EqualizePattern has a unique 'back'
343 std::map<std::string, EqualizePattern *> pattern_by_back;
344 {
345 for (auto &pattern : _patterns)
346 {
347 auto back = pattern.back;
348 pattern_by_back[back] = &pattern;
349 }
350 }
351
352 for (auto node : loco::postorder_traversal(loco::output_nodes(g)))
353 {
354 auto cnode = loco::must_cast<luci::CircleNode *>(node);
355
356 if (pattern_by_back.find(cnode->name()) == pattern_by_back.end())
357 continue;
358
359 auto pattern = pattern_by_back.at(cnode->name());
360 InsertScaleShiftVisitor issv(pattern);
361 cnode->accept(&issv);
362 }
363}
std::vector< loco::Node * > postorder_traversal(const std::vector< loco::Node * > &roots)
Generate postorder traversal sequence starting from "roots".
Definition Algorithm.cpp:53
std::vector< Node * > output_nodes(Graph *)
Definition Graph.cpp:101

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

Referenced by fme_apply::FMEqualizer::equalize().


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