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

#include <Identity.h>

Collaboration diagram for moco::IdentityGraphBuilder:

Public Member Functions

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

Detailed Description

Definition at line 25 of file Identity.h.

Member Function Documentation

◆ build()

void moco::IdentityGraphBuilder::build ( const tensorflow::NodeDef &  node,
GraphBuilderContext context 
) const
finalvirtual

Implements moco::GraphBuilder.

Definition at line 69 of file Identity.cpp.

71{
72 loco::Graph *graph = context->graph();
73 SymbolTable *tensor_names = context->tensor_names();
74 UpdateQueue *updates = context->updates();
75
76 // Create a Identity node
77 auto identity_node = graph->nodes()->create<TFIdentity>();
78 identity_node->name(node.name());
79
80 // register string-name to node
81 TensorName output_name(node.name(), 0);
82 tensor_names->enroll(output_name, identity_node);
83
84 // Queue node input update
85 // TODO: Check if we really need multiple input handlings
86 std::vector<TensorName> names;
87 for (int i = 0; i < node.input_size(); ++i)
88 {
89 names.emplace_back(TensorName(node.input(i)));
90 }
91 auto update = std::make_unique<TFIdentityGraphUpdate>(identity_node, names);
92 updates->enroll(std::move(update));
93}
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.
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)
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(), moco::update(), and moco::GraphBuilderContext::updates().

◆ validate()

bool moco::IdentityGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
finalvirtual

Implements moco::GraphBuilder.

Definition at line 61 of file Identity.cpp.

62{
63 if (node.input_size() < 1) // from TensorFlow lite toco
64 return false;
65
66 return true;
67}

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