ONE - On-device Neural Engine
Loading...
Searching...
No Matches
logo::ResolveRedundantReshapePass Class Referencefinal

Remove redundant canonical FixedReshape. More...

#include <ResolveRedundantReshapePass.h>

Collaboration diagram for logo::ResolveRedundantReshapePass:

Public Member Functions

const char * name (void) const final
 
bool run (loco::Graph *graph) override
 Bypass redundant FixedReshape.
 
- Public Member Functions inherited from logo::Pass
virtual ~Pass ()=default
 

Detailed Description

Remove redundant canonical FixedReshape.

Note
To effectively run this transform, canonical shape inference should be done ahead

Definition at line 33 of file ResolveRedundantReshapePass.h.

Member Function Documentation

◆ name()

const char * logo::ResolveRedundantReshapePass::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 36 of file ResolveRedundantReshapePass.h.

36{ return "ResolveRedundantReshapePass"; }

◆ run()

bool logo::ResolveRedundantReshapePass::run ( loco::Graph graph)
overridevirtual

Bypass redundant FixedReshape.

Before:

In --— FixedReshape --— [Out]*

After:

In ---------------------— [Out]* \ ---— FixedReshape

Implements logo::Pass.

Definition at line 82 of file ResolveRedundantReshapePass.cpp.

83{
84 bool changed = false;
85 for (auto node : loco::postorder_traversal(loco::output_nodes(graph)))
86 {
87 if (auto reshape = dynamic_cast<loco::FixedReshape *>(node))
88 {
89 if (shape_inference_done(reshape))
90 {
91 if (is_redundant_reshape(reshape))
92 {
93 replace(reshape).with(reshape->input());
94 changed = true;
95 }
96 }
97 }
98 }
99
100 return changed;
101}
Reshape a tensor to another tensor whose shape is known at compile time.
Definition Nodes.h:517
void with(Node *into) const
Definition Node.cpp:66
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
Subst< SubstQualifier::Default > replace(Node *node)
Definition Node.cpp:82
bool shape_inference_done(const loco::Node *node)
Return true if node has shape inference data for checking shape inference is done or not.

References loco::output_nodes(), loco::postorder_traversal(), and loco::Subst< SubstQualifier::Default >::with().

Referenced by package.infer.session::inference().


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