ONE - On-device Neural Engine
Loading...
Searching...
No Matches
GraphBuilderContext.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __MOCO_FRONTEND_ONNX_GRAPHBUILDERCONTEXT_H__
18#define __MOCO_FRONTEND_ONNX_GRAPHBUILDERCONTEXT_H__
19
20#include <loco.h>
21
22#include <map>
23#include <string>
24#include <vector>
25
26namespace moco
27{
28namespace onnx
29{
30
35{
36public:
40 void enroll(const std::string &node_name, loco::Node *node);
46 loco::Node *node(const std::string &node_name);
47
52 void list(loco::Node *node, const std::string &name);
56 unsigned size(loco::Node *node);
61 const std::string &name(loco::Node *node, unsigned index);
62
63private:
64 using MapNameNode_t = std::map<std::string, loco::Node *>;
65 using MapNodeNames_t = std::map<loco::Node *, std::vector<std::string>>;
66
67 MapNameNode_t _namenode;
68 MapNodeNames_t _nodenames;
69};
70
75{
76public:
78 : _g(g), _nodes(nodes), _input_names(input_names)
79 {
80 // DO NOTHING
81 }
82
85
86public:
87 loco::Graph *graph() { return _g; }
88 SymbolTable *nodes() { return _nodes; }
89 SymbolTable *input_names() { return _input_names; }
90
91private:
92 loco::Graph *_g;
93 SymbolTable *_nodes;
94 SymbolTable *_input_names;
95};
96
97} // namespace onnx
98} // namespace moco
99
100#endif // __MOCO_FRONTEND_ONNX_GRAPHBUILDERCONTEXT_H__
A neural network graph.
Definition Graph.h:161
Logical unit of computation.
Definition Node.h:54
Class to store context to build IR from onnx.
GraphBuilderContext(const GraphBuilderContext &)=delete
GraphBuilderContext(loco::Graph *g, SymbolTable *nodes, SymbolTable *input_names)
GraphBuilderContext(GraphBuilderContext &&)=delete
Class to store relations of Nodes and string names.
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 ...
void enroll(const std::string &node_name, loco::Node *node)
Registers one node for a name.
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...
void list(loco::Node *node, const std::string &name)
Registers multiple (appends) names for a node Table is independent with registering with enroll()
Definition Log.h:23
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54
int32_t size[5]
Definition Slice.cpp:35