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

#include <Pack.h>

Collaboration diagram for moco::PackGraphBuilder:

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 Pack.h.

Member Function Documentation

◆ build()

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

Implements moco::GraphBuilder.

Definition at line 75 of file Pack.cpp.

76{
77 assert(context != nullptr);
78
79 auto graph = context->graph();
80 auto tensor_names = context->tensor_names();
81 auto updates = context->updates();
82
83 const int num_inputs = node.input_size();
84 std::vector<TensorName> input_names;
85 auto pack_node = graph->nodes()->create<TFPack>(num_inputs);
86 pack_node->name(node.name());
87
88 for (int ni = 0; ni < num_inputs; ++ni)
89 {
90 input_names.push_back(TensorName(node.input(ni)));
91 }
92
93 pack_node->axis(plier::tf::get_int_attr(node, "axis"));
94
95 TensorName output_name(node.name(), 0);
96 tensor_names->enroll(output_name, pack_node);
97
98 auto update = std::make_unique<TFPackGraphUpdate>(pack_node, input_names);
99 updates->enroll(std::move(update));
100}
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)
int64_t get_int_attr(const tensorflow::NodeDef &node, const std::string &attr_name)
Definition Convert.cpp:87
NodeName name(void) const
Definition TFNodeDecl.h:50

References moco::SymbolTable::enroll(), plier::tf::get_int_attr(), moco::GraphBuilderContext::graph(), moco::TFNode::name(), moco::GraphBuilderContext::tensor_names(), moco::update(), and moco::GraphBuilderContext::updates().

◆ validate()

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

Implements moco::GraphBuilder.

Definition at line 66 of file Pack.cpp.

67{
68 if (!plier::tf::has_attrs(node, {"T", "N", "axis"}))
69 return false;
70
71 const int num_inputs = node.input_size();
72 return (num_inputs >= 1) && (num_inputs == plier::tf::get_int_attr(node, "N"));
73}
bool has_attrs(const tensorflow::NodeDef &node, const std::vector< std::string > &attr_names)
Definition Convert.cpp:35

References plier::tf::get_int_attr(), and plier::tf::has_attrs().


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