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

GraphBuilder for Add node. More...

#include <Add.h>

Collaboration diagram for moco::AddGraphBuilder:

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 Add node.

Definition at line 28 of file Add.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 63 of file Add.cpp.

64{
65 assert(context != nullptr);
66
67 loco::Graph *graph = context->graph();
68 SymbolTable *tensor_names = context->tensor_names();
69 UpdateQueue *updates = context->updates();
70
71 // creating TF dialect Add node
72 auto tf_add = graph->nodes()->create<TFAdd>();
73 tf_add->name(node.name());
74
75 TensorName output_name(node.name(), 0);
76 tensor_names->enroll(output_name, tf_add);
77
78 std::vector<TensorName> add_input_names;
79 add_input_names.push_back(TensorName(node.input(0))); // x
80 add_input_names.push_back(TensorName(node.input(1))); // y
81
82 auto tf_add_update = std::make_unique<TFAddGraphUpdate>(tf_add, add_input_names);
83 updates->enroll(std::move(tf_add_update));
84}
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.
NodeName name(void) const
Definition TFNodeDecl.h:50

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

◆ validate()

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

Implements moco::GraphBuilder.

Definition at line 58 of file Add.cpp.

59{
60 return node.input_size() == 2;
61}

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