ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::FuseBinaryIntoPreceding Class Reference

Fuse TFAdd, TFMul to preceding TFConv2D or TFDepthWiseConv2D. More...

#include <FuseBinaryIntoPreceding.h>

Collaboration diagram for moco::FuseBinaryIntoPreceding:

Public Member Functions

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

Detailed Description

Fuse TFAdd, TFMul to preceding TFConv2D or TFDepthWiseConv2D.

Definition at line 30 of file FuseBinaryIntoPreceding.h.

Member Function Documentation

◆ name()

const char * moco::FuseBinaryIntoPreceding::name ( void  ) const
inlinefinalvirtual

Reimplemented from logo::Pass.

Definition at line 33 of file FuseBinaryIntoPreceding.h.

33{ return "FuseBinaryIntoPreceding"; }

◆ run()

bool moco::FuseBinaryIntoPreceding::run ( loco::Graph graph)
overridevirtual

Run the pass.

Returns
false if there was nothing changed

Implements logo::Pass.

Definition at line 500 of file FuseBinaryIntoPreceding.cpp.

501{
502 bool changed = false;
504
505 for (auto node : active_nodes)
506 {
507 if (node->dialect() == moco::TFDialect::get())
508 {
509 {
510 auto tf_node = dynamic_cast<moco::TFMul *>(node);
511 if (tf_node != nullptr)
512 {
513 if (fuse_to_preceding(graph, tf_node))
514 changed = true;
515 }
516 }
517 {
518 // TODO support Div
519 }
520
521 {
522 auto tf_node = dynamic_cast<moco::TFAdd *>(node);
523 if (tf_node != nullptr)
524 {
525 if (fuse_to_preceding(graph, tf_node))
526 changed = true;
527 }
528 }
529 {
530 // TODO support Sub
531 }
532 }
533 }
534
535 return changed;
536}
static loco::Dialect * get(void)
Definition TFDialect.cpp:84
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(), moco::TFNode::dialect(), moco::TFDialect::get(), and loco::output_nodes().

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


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