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

GraphBuilder for Sub node. More...

#include <Sub.h>

Collaboration diagram for moco::SubGraphBuilder:

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

Definition at line 28 of file Sub.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 63 of file Sub.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 Sub node
72 auto tf_sub = graph->nodes()->create<TFSub>();
73 tf_sub->name(node.name());
74
75 TensorName output_name(node.name(), 0);
76 tensor_names->enroll(output_name, tf_sub);
77
78 std::vector<TensorName> sub_input_names;
79 sub_input_names.push_back(TensorName(node.input(0))); // x
80 sub_input_names.push_back(TensorName(node.input(1))); // y
81
82 auto tf_sub_update = std::make_unique<TFSubGraphUpdate>(tf_sub, sub_input_names);
83 updates->enroll(std::move(tf_sub_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::SubGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 58 of file Sub.cpp.

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

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