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

Class to Forward Transpose Ops for further optimization. More...

#include <ForwardTransposeOpPass.h>

Collaboration diagram for luci::ForwardTransposeOpPass:

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 Forward Transpose Ops for further optimization.

Definition at line 28 of file ForwardTransposeOpPass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 30 of file ForwardTransposeOpPass.h.

30{ return "luci::ForwardTransposeOpPass"; }

◆ run()

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

BEFORE

            [CircleNode]     [CircleNode]
                  |              |
         [CircleTranspose] [CircleTranspose]
                  |       /
               [(BinaryOp)]
                    |

BinaryOp: CircleAdd, CircleMul, ...

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

[CircleNode] [(BinaryOp)] | | \ | | [CircleNode] | | |

BinaryOp: CircleAdd, CircleMul, ...

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

[CircleNode] [(UnaryOp)] | | \ | | [CircleNode] | | |

UnaryOp: CircleAbs, ...

AFTER

         [CircleNode] [CircleNode]
                  |       /
               [(BinaryOp)]
                    |
            [CircleTranspose]
                    |

BinaryOp: CircleAdd, CircleMul, ...

                |

[CircleConst] [CircleNode] [CircleConst(updated)] | / | / [CircleTranspose] [(BinaryOp)] [CircleConst] | | / [CircleNode] [CircleTranspose] | | \ | | [CircleNode] | | |

          |

[CircleConst] [CircleNode] | / | [CircleTranspose] [(UnaryOp)] [CircleConst] | | / [CircleNode] [CircleTranspose] | | \ | | [CircleNode] | | |

Note: new [CircleTranspose] is added after [(BinaryOp)]

Implements logo::Pass.

Definition at line 491 of file ForwardTransposeOpPass.cpp.

492{
493 bool changed = false;
494
495 // TODO Revisit pattern interface
496 EBOPattern ebo;
497 EBOWithConstPattern eboc;
498 EwUnaryPattern ewu;
499 for (auto node : loco::active_nodes(loco::output_nodes(g)))
500 {
501 auto circle_node = loco::must_cast<luci::CircleNode *>(node);
502 if (circle_node->accept(&eboc))
503 changed = true;
504 else if (circle_node->accept(&ewu))
505 changed = true;
506 else if (circle_node->accept(&ebo))
507 changed = true;
508 }
509 return changed;
510}
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: