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 charname (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 1515 of file FuseInstanceNormPass.cpp.

1516{
1517 bool changed = false;
1518
1519 // Check Version_1, Version_2, Version_3, Version_5, Version_6
1520 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1521 {
1522 auto add = dynamic_cast<luci::CircleAdd *>(node);
1523 if (not add)
1524 continue;
1525
1526 if (fuse_instance_norm(add))
1527 changed = true;
1528 }
1529
1530 // Check Version_4(from DIV) if MUL-ADD pattern is not found
1531 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1532 {
1533 auto div = dynamic_cast<luci::CircleDiv *>(node);
1534 if (not div)
1535 continue;
1536
1537 if (fuse_instance_norm(div))
1538 changed = true;
1539 }
1540
1541 // Check Version_7(from Reshape) if other versions not found
1542 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1543 {
1544 auto reshape = dynamic_cast<luci::CircleReshape *>(node);
1545 if (not reshape)
1546 continue;
1547
1548 if (fuse_instance_norm(reshape))
1549 changed = true;
1550 }
1551
1552 // Post processing of FuseInstanceNorm
1553 for (auto node : loco::active_nodes(loco::output_nodes(g)))
1554 {
1555 auto inst_norm = dynamic_cast<luci::CircleInstanceNorm *>(node);
1556 if (not inst_norm)
1557 continue;
1558
1560 changed = true;
1561 }
1562
1563 return changed;
1564}
ADD in Circle.
Definition CircleAdd.h:34
DIV in Circle.
Definition CircleDiv.h:37
INSTANCE_NORM in Circle.
RESHAPE 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
T must_cast(loco::Node *node)

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


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