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

GraphBuilder for Reshape node. More...

#include <Reshape.h>

Collaboration diagram for moco::ReshapeGraphBuilder:

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

Definition at line 28 of file Reshape.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 74 of file Reshape.cpp.

75{
76 assert(context != nullptr);
77
78 loco::Graph *graph = context->graph();
79 SymbolTable *tensor_names = context->tensor_names();
80 UpdateQueue *updates = context->updates();
81
82 // name of loco nodes
83 std::string reshape_name = node.name();
84
85 auto reshape = graph->nodes()->create<TFReshape>();
86 reshape->name(node.name());
87
88 // save the name for graph link updates
89 TensorName output_name(reshape_name, 0);
90 tensor_names->enroll(output_name, reshape);
91
92 std::vector<TensorName> input_names;
93 input_names.push_back(TensorName(node.input(0))); // tensor
94 input_names.push_back(TensorName(node.input(1))); // shape
95
96 // Queue node input update
97 auto update = std::make_unique<ReshapeGraphUpdate>(reshape, input_names);
98
99 updates->enroll(std::move(update));
100}
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)

References moco::SymbolTable::enroll(), moco::UpdateQueue::enroll(), moco::GraphBuilderContext::graph(), moco::GraphBuilderContext::tensor_names(), moco::update(), and moco::GraphBuilderContext::updates().

◆ validate()

bool moco::ReshapeGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 64 of file Reshape.cpp.

65{
66 // Tensorflow Reshape has 2 inputs: tensor & shape
67 if (node.input_size() != 2)
68 return false;
69
70 // TODO Assert Tshape value is DT_INT32?
71 return plier::tf::has_attrs(node, {"T", "Tshape"});
72}
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: