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

Class to Remove Unnecessary(input and output are same) StridedSlice node. More...

#include <RemoveUnnecessaryStridedSlicePass.h>

Collaboration diagram for luci::RemoveUnnecessaryStridedSlicePass:

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 Remove Unnecessary(input and output are same) StridedSlice node.

Definition at line 28 of file RemoveUnnecessaryStridedSlicePass.h.

Member Function Documentation

◆ name()

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

Reimplemented from logo::Pass.

Definition at line 30 of file RemoveUnnecessaryStridedSlicePass.h.

30{ return "luci::RemoveUnnecessaryStridedSlicePass"; }

◆ run()

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

BEFORE

[CircleNode] | [CircleStridedSlice] | [CircleNode]

AFTER

[CircleNode] | [CircleNode] [CircleStridedSlice]

StridedSlice OP has no effect if,

  1. Static Shape : begin_const[idx] is 0 AND strides_const[idx] is (not 1 OR input_dimension[idx])
  2. Dynamic Shape : begin_const[idx] is 0 AND strides_const[idx] is not 1

StridedSlice OP has effect if,

  1. begin_const[idx] is 0 AND input_shape[idx] are equal to end_shape[idx]

Implements logo::Pass.

Definition at line 111 of file RemoveUnnecessaryStridedSlicePass.cpp.

112{
113 bool changed = false;
114 for (auto node : loco::active_nodes(loco::output_nodes(g)))
115 {
116 auto target_node = dynamic_cast<luci::CircleStridedSlice *>(node);
117 if (target_node != nullptr)
118 if (remove_no_effect_strided_slice(target_node))
119 changed = true;
120 }
121 return changed;
122}
STRIDED_SLICE 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: