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

GraphBuilder for SquaredDifference node. More...

#include <SquaredDifference.h>

Collaboration diagram for moco::SquaredDifferenceGraphBuilder:

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

Definition at line 28 of file SquaredDifference.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 66 of file SquaredDifference.cpp.

68{
69 assert(context != nullptr);
70
71 loco::Graph *graph = context->graph();
72 SymbolTable *tensor_names = context->tensor_names();
73 UpdateQueue *updates = context->updates();
74
75 // creating TF dialect SquaredDifference node
76 auto tf_sqdiff = graph->nodes()->create<TFSquaredDifference>();
77 tf_sqdiff->name(node.name());
78
79 // register string-name to node
80 TensorName output_name(node.name(), 0);
81 tensor_names->enroll(output_name, tf_sqdiff);
82
83 std::vector<TensorName> add_input_names;
84 add_input_names.push_back(TensorName(node.input(0))); // x
85 add_input_names.push_back(TensorName(node.input(1))); // y
86
87 // Queue node input update
88 auto tf_sqrt_update =
89 std::make_unique<TFSquaredDifferenceGraphUpdate>(tf_sqdiff, add_input_names);
90 updates->enroll(std::move(tf_sqrt_update));
91}
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::SquaredDifferenceGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 61 of file SquaredDifference.cpp.

62{
63 return node.input_size() == 2;
64}

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