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

Class to fuse certain pattern of subgraph into CircleInstanceNorm with auxiliary nodes. More...

#include <FuseInstanceNormPass.h>

Collaboration diagram for luci::FuseInstanceNormPass:

Public Member Functions

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

Detailed Description

Class to fuse certain pattern of subgraph into CircleInstanceNorm with auxiliary nodes.

For detailed subgraph pattern to be fused, please check its implementation.

Definition at line 31 of file FuseInstanceNormPass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 33 of file FuseInstanceNormPass.h.

33{ return "luci::FuseInstanceNormPass"; }

◆ run()

bool luci::FuseInstanceNormPass::run ( loco::Graph graph)
finalvirtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 1271 of file FuseInstanceNormPass.cpp.

1272{
1273 bool changed = false;
1274
1275 // Check Version_1, Version_2, Version_3, Version_5, Version_6
1276 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1277 {
1278 auto add = dynamic_cast<luci::CircleAdd *>(node);
1279 if (not add)
1280 continue;
1281
1282 if (fuse_instance_norm(add))
1283 changed = true;
1284 }
1285
1286 // Check Version_4(from DIV) if MUL-ADD pattern is not found
1287 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1288 {
1289 auto div = dynamic_cast<luci::CircleDiv *>(node);
1290 if (not div)
1291 continue;
1292
1293 if (fuse_instance_norm(div))
1294 changed = true;
1295 }
1296
1297 // Post processing of FuseInstanceNorm
1298 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1299 {
1300 auto inst_norm = dynamic_cast<luci::CircleInstanceNorm *>(node);
1301 if (not inst_norm)
1302 continue;
1303
1304 if (post_fusion(inst_norm))
1305 changed = true;
1306 }
1307
1308 return changed;
1309}
ADD in Circle.
Definition CircleAdd.h:34
DIV in Circle.
Definition CircleDiv.h:37
INSTANCE_NORM in Circle.
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: