ONE - On-device Neural Engine
Loading...
Searching...
No Matches
moco::FusedBatchNormGraphBuilder Class Referencefinal

GraphBuilder for FusedBatchNorm node. More...

#include <FusedBatchNorm.h>

Collaboration diagram for moco::FusedBatchNormGraphBuilder:

Public Member Functions

bool validate (const tensorflow::NodeDef &) const override
 
void build (const tensorflow::NodeDef &, GraphBuilderContext *) const override
 
- Public Member Functions inherited from moco::GraphBuilder
virtual ~GraphBuilder ()
 

Detailed Description

GraphBuilder for FusedBatchNorm node.

Definition at line 28 of file FusedBatchNorm.h.

Member Function Documentation

◆ build()

void moco::FusedBatchNormGraphBuilder::build ( const tensorflow::NodeDef &  node,
GraphBuilderContext context 
) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 73 of file FusedBatchNorm.cpp.

75{
76 assert(context != nullptr);
77
78 loco::Graph *graph = context->graph();
79 SymbolTable *tensor_names = context->tensor_names();
80 UpdateQueue *updates = context->updates();
81
82 float epsilon = plier::tf::get_float_attr(node, "epsilon");
83
84 // creating TF dialect FusedBatchNorm node
85 auto tf_fbn = graph->nodes()->create<TFFusedBatchNorm>();
86 tf_fbn->name(node.name());
87 tf_fbn->epsilon(epsilon);
88
89 TensorName output_name(node.name(), 0);
90 tensor_names->enroll(output_name, tf_fbn);
91
92 std::vector<TensorName> fbn_input_names;
93 fbn_input_names.push_back(TensorName(node.input(0))); // input
94 fbn_input_names.push_back(TensorName(node.input(1))); // scale
95 fbn_input_names.push_back(TensorName(node.input(2))); // offset
96 fbn_input_names.push_back(TensorName(node.input(3))); // mean
97 fbn_input_names.push_back(TensorName(node.input(4))); // variance
98
99 auto tf_fbn_update = std::make_unique<FusedBatchNormGraphUpdate>(tf_fbn, fbn_input_names);
100 updates->enroll(std::move(tf_fbn_update));
101}
A neural network graph.
Definition Graph.h:161
Class to store and query loco::Node* with string name key.
void enroll(const TensorName &tensor_name, loco::Node *node)
Registers a name with corresponding loco::Node *.
Class to store GraphUpdate objects.
void enroll(std::unique_ptr< GraphUpdate > &&update)
Registers GraphUpdate objects.
float get_float_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:95
NodeName name(void) const
Definition TFNodeDecl.h:50

References moco::SymbolTable::enroll(), moco::UpdateQueue::enroll(), plier::tf::get_float_attr(), moco::GraphBuilderContext::graph(), moco::TFNode::name(), moco::GraphBuilderContext::tensor_names(), and moco::GraphBuilderContext::updates().

◆ validate()

bool moco::FusedBatchNormGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 65 of file FusedBatchNorm.cpp.

66{
67 if (node.input_size() != 5)
68 return false;
69
70 return plier::tf::has_attrs(node, {"epsilon"});
71}
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
Definition Convert.cpp:35

References plier::tf::has_attrs().


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