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

Class to substitute PadV2 in certain condition to Pad. More...

#include <SubstitutePadV2ToPadPass.h>

Collaboration diagram for luci::SubstitutePadV2ToPadPass:

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 substitute PadV2 in certain condition to Pad.

Definition at line 28 of file SubstitutePadV2ToPadPass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 30 of file SubstitutePadV2ToPadPass.h.

30{ return "luci::SubstitutePadV2ToPadPass"; }

◆ run()

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

Case 1) Basic case

BEFORE [CircleRelu] | | [CircleConst] [CircleConst] | | | ----—+-------------------— | [CirclePadV2] | [CircleMaxPool2D] |

AFTER [CircleRelu] | | [CircleConst] [CircleNode] [CircleConst] | | | | | ----—+----— ----------—+-----------—+ | | [CirclePad] [CirclePadV2] | [CircleMaxPool2D] |

Case 2) During conversion from a PyTorch model into a Circle model, it is common that some 'Reshaping op', e.g., CircleTranspose, are inserted in-between operations to swith NCHW into NHWC and vice versa. This pass also needs to handle such situation.

BEFORE [CircleRelu] | | [CircleConst] [CircleConst] | | | ----—+-------------------— | [CircleTranspose] | [CirclePadV2] | [CircleTranspose] | [CircleMaxPool2D] |

AFTER [CircleRelu] | | [CircleConst] [CircleNode] [CircleConst] | | | | | ----—+----— ----------—+-----------—+ | | [CircleTranspose] [CirclePadV2] | [CirclePad] | [CircleTranspose] | [CircleMaxPool2D] |

Implements logo::Pass.

Definition at line 453 of file SubstitutePadV2ToPadPass.cpp.

454{
455 bool changed = false;
456 for (auto node : loco::active_nodes(loco::output_nodes(g)))
457 {
458 if (auto circle_node = dynamic_cast<luci::CircleMaxPool2D *>(node))
459 {
460 if (substitute_padv2_to_pad(circle_node))
461 {
462 changed = true;
463 }
464 }
465 }
466 return changed;
467}
MAX_POOL_2D 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: