ONE - On-device Neural Engine
Loading...
Searching...
No Matches
fme_detect::EqualizePatternFinder Class Referencefinal

#include <EqualizePatternFinder.h>

Data Structures

struct  Context
 

Public Member Functions

 EqualizePatternFinder (const Context &ctx)
 
std::vector< EqualizePatternfind (loco::Graph *) const
 

Detailed Description

Definition at line 30 of file EqualizePatternFinder.h.

Constructor & Destructor Documentation

◆ EqualizePatternFinder()

fme_detect::EqualizePatternFinder::EqualizePatternFinder ( const Context ctx)
inline

Definition at line 39 of file EqualizePatternFinder.h.

39: _ctx(ctx) {}

Member Function Documentation

◆ find()

std::vector< EqualizePattern > fme_detect::EqualizePatternFinder::find ( loco::Graph g) const

Definition at line 267 of file EqualizePatternFinder.cpp.

268{
269 if (g == nullptr)
270 throw std::invalid_argument("g");
271
272 std::vector<EqualizePattern> res;
273 for (auto node : loco::active_nodes(loco::output_nodes(g)))
274 {
275 const auto cnode = loco::must_cast<luci::CircleNode *>(node);
276 if (not _ctx._allow_dup_op)
277 {
278 // We create new Ops (front, back) for each matched pattern, so duplicate
279 // Ops can be created. This condition prevents pattern matching for a node
280 // (front) with multiple successors (backs) to avoid duplicate computation.
281 // TODO Duplicate Ops can be removed if all (pred-succ) pairs are matched
282 // as the same pattern. For example, if (pred-succ1) is ScaleOnly and
283 // (pred-succ2) is ScaleOnly, pred does not need to be duplicated.
284 if (loco::succs(cnode).size() != 1)
285 continue;
286 }
287
288 ::match(cnode, res);
289 }
290
291 return res;
292}
std::set< Node * > succs(const Node *node)
Enumerate all the successors of a given node.
Definition Node.cpp:46
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
int32_t size[5]
Definition Slice.cpp:35

References fme_detect::EqualizePatternFinder::Context::_allow_dup_op, loco::active_nodes(), loco::output_nodes(), size, and loco::succs().

Referenced by entry().


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