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

GraphBuilder for Relu node. More...

#include <Relu.h>

Collaboration diagram for moco::ReluGraphBuilder:

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

GraphBuilder for Relu node.

Definition at line 28 of file Relu.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 65 of file Relu.cpp.

66{
67 assert(context != nullptr);
68
69 loco::Graph *graph = context->graph();
70 SymbolTable *tensor_names = context->tensor_names();
71 UpdateQueue *updates = context->updates();
72
73 // Create a "TFRelu" node for Relu
74 auto relu_node = graph->nodes()->create<TFRelu>();
75 relu_node->name(node.name());
76
77 // register string-name to node
78 TensorName output_name(node.name(), 0);
79 tensor_names->enroll(output_name, relu_node);
80
81 // Queue node input update
82 auto update = std::make_unique<TFReluGraphUpdate>(relu_node, TensorName(node.input(0)));
83 updates->enroll(std::move(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.
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::ReluGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
finalvirtual

Implements moco::GraphBuilder.

Definition at line 56 of file Relu.cpp.

57{
58 // ReLU node SHOULD have only one input
59 if (node.input_size() != 1)
60 return false;
61
62 return true;
63}

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