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

Class to store relations of Nodes and string names. More...

#include <GraphBuilderContext.h>

Public Member Functions

void enroll (const std::string &node_name, loco::Node *node)
 Registers one node for a name.
 
loco::Nodenode (const std::string &node_name)
 Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found Table is independent with registering with list()
 
void list (loco::Node *node, const std::string &name)
 Registers multiple (appends) names for a node Table is independent with registering with enroll()
 
unsigned size (loco::Node *node)
 Returns number of listed(registered) names for a node.
 
const std::string & name (loco::Node *node, unsigned index)
 Queries listed(registered) with node and index(from 0 to size-1) Will throw runtime_error if node is not found or index is out of bounds.
 

Detailed Description

Class to store relations of Nodes and string names.

Definition at line 34 of file GraphBuilderContext.h.

Member Function Documentation

◆ enroll()

void moco::onnx::SymbolTable::enroll ( const std::string &  node_name,
loco::Node node 
)

Registers one node for a name.

Definition at line 24 of file GraphBuilderContext.cpp.

25{
26 MapNameNode_t::iterator iter = _namenode.find(node_name);
27
28 if (iter != _namenode.end())
29 {
30 throw std::runtime_error{"Error: Duplicate node name in Graph: " + node_name};
31 }
32
33 _namenode[node_name] = node;
34}
loco::Node * node(const std::string &node_name)
Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found...

References node().

Referenced by moco::onnx::Constant_V1::build(), moco::onnx::Constant_V9::build(), and moco::onnx::Identity_V1::build().

◆ list()

void moco::onnx::SymbolTable::list ( loco::Node node,
const std::string &  name 
)

Registers multiple (appends) names for a node Table is independent with registering with enroll()

Definition at line 48 of file GraphBuilderContext.cpp.

49{
50 MapNodeNames_t::iterator iter = _nodenames.find(node);
51
52 if (iter == _nodenames.end())
53 {
54 // add a new vector for the first name
55 _nodenames[node] = {name};
56 return;
57 }
58
59 _nodenames[node].push_back(name);
60}
const std::string & name(loco::Node *node, unsigned index)
Queries listed(registered) with node and index(from 0 to size-1) Will throw runtime_error if node is ...

References name(), and node().

Referenced by moco::onnx::Identity_V1::build().

◆ name()

const std::string & moco::onnx::SymbolTable::name ( loco::Node node,
unsigned  index 
)

Queries listed(registered) with node and index(from 0 to size-1) Will throw runtime_error if node is not found or index is out of bounds.

Definition at line 74 of file GraphBuilderContext.cpp.

75{
76 MapNodeNames_t::iterator iter = _nodenames.find(node);
77
78 if (iter == _nodenames.end())
79 {
80 throw std::runtime_error{"Error: Cannot find names given node"};
81 }
82
83 if (index >= iter->second.size())
84 {
85 throw std::runtime_error{"Error: Invalid name index for given node"};
86 }
87
88 return iter->second.at(index);
89}
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References moco::index(), and node().

Referenced by list().

◆ node()

loco::Node * moco::onnx::SymbolTable::node ( const std::string &  node_name)

Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found Table is independent with registering with list()

Definition at line 36 of file GraphBuilderContext.cpp.

37{
38 MapNameNode_t::iterator iter = _namenode.find(node_name);
39
40 if (iter == _namenode.end())
41 {
42 throw std::runtime_error{"Error: Cannot find node with name in Graph: " + node_name};
43 }
44
45 return iter->second;
46}

Referenced by enroll(), list(), name(), and size().

◆ size()

unsigned moco::onnx::SymbolTable::size ( loco::Node node)

Returns number of listed(registered) names for a node.

Definition at line 62 of file GraphBuilderContext.cpp.

63{
64 MapNodeNames_t::iterator iter = _nodenames.find(node);
65
66 if (iter == _nodenames.end())
67 {
68 return 0;
69 }
70
71 return iter->second.size();
72}

References node().


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