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

GraphBuilder for Softmax node. More...

#include <Softmax.h>

Collaboration diagram for moco::SoftmaxGraphBuilder:

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

Definition at line 28 of file Softmax.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 68 of file Softmax.cpp.

69{
70 assert(context != nullptr);
71
72 loco::Graph *graph = context->graph();
73 SymbolTable *tensor_names = context->tensor_names();
74 UpdateQueue *updates = context->updates();
75
76 // creating TF dialect Softmax node
77 auto tf_softmax = graph->nodes()->create<TFSoftmax>();
78 tf_softmax->name(node.name());
79
80 TensorName output_name(node.name(), 0);
81 tensor_names->enroll(output_name, tf_softmax);
82
83 auto update = std::make_unique<SoftmaxGraphUpdate>(tf_softmax, TensorName(node.input(0)));
84 updates->enroll(std::move(update));
85}
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::SoftmaxGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 60 of file Softmax.cpp.

61{
62 if (node.input_size() != 1)
63 return false;
64
65 return plier::tf::has_attrs(node, {"T"});
66}
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
Definition Convert.cpp:35

References plier::tf::has_attrs().


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