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

GraphBuilder for Pad node. More...

#include <Pad.h>

Collaboration diagram for moco::PadGraphBuilder:

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

Definition at line 28 of file Pad.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 67 of file Pad.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 Pad node
76 auto tf_pad = graph->nodes()->create<TFPad>();
77 tf_pad->name(node.name());
78
79 // register string-name to node
80 TensorName output_name(node.name(), 0);
81 tensor_names->enroll(output_name, tf_pad);
82
83 std::vector<TensorName> add_input_names;
84 add_input_names.push_back(TensorName(node.input(0))); // input
85 add_input_names.push_back(TensorName(node.input(1))); // paddings
86
87 // Queue node input update
88 auto tf_pad_update = std::make_unique<TFPadGraphUpdate>(tf_pad, add_input_names);
89 updates->enroll(std::move(tf_pad_update));
90}
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::PadGraphBuilder::validate ( const tensorflow::NodeDef &  node) const
overridevirtual

Implements moco::GraphBuilder.

Definition at line 59 of file Pad.cpp.

60{
61 if (node.input_size() != 2)
62 return false;
63
64 return plier::tf::has_attrs(node, {"T", "Tpaddings"});
65}
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: