ONE - On-device Neural Engine
Loading...
Searching...
No Matches
GraphBuilderContext.cpp
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
18
19#include <oops/UserExn.h>
20
21#include <stdexcept>
22#include <string>
23
24namespace moco
25{
26
27void NodeDefTable::enroll(const std::string &node_name, const tensorflow::NodeDef *node)
28{
29 MapNameNode_t::iterator iter = _table.find(node_name);
30
31 if (iter != _table.end())
32 {
33 throw oops::UserExn("Duplicate node name in GraphDef", node_name);
34 }
35
36 _table[node_name] = node;
37}
38
39const tensorflow::NodeDef *NodeDefTable::node(const std::string &node_name) const
40{
41 MapNameNode_t::const_iterator iter = _table.find(node_name);
42
43 if (iter == _table.end())
44 {
45 throw oops::UserExn("Cannot find node with name in GraphDef", node_name);
46 }
47
48 return iter->second;
49}
50
51void SymbolTable::enroll(const TensorName &tensor_name, loco::Node *node)
52{
53 MapNameNode_t::iterator iter = _table.find(tensor_name);
54
55 if (iter != _table.end())
56 {
57 throw oops::UserExn("Duplicate node name in GraphDef", tensor_name.name());
58 }
59
60 _table[tensor_name] = node;
61}
62
63loco::Node *SymbolTable::node(const TensorName &tensor_name) const
64{
65 MapNameNode_t::const_iterator iter = _table.find(tensor_name);
66
67 if (iter == _table.end())
68 {
69 throw oops::UserExn("Cannot find node with name in GraphDef", tensor_name.name());
70 }
71
72 return iter->second;
73}
74
75void UpdateQueue::enroll(std::unique_ptr<GraphUpdate> &&update)
76{
77 _queue.push_back(std::move(update));
78}
79
80} // namespace moco
Logical unit of computation.
Definition Node.h:54
const tensorflow::NodeDef * node(const std::string &node_name) const
Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found...
void enroll(const std::string &node_name, const tensorflow::NodeDef *node)
Registers a name with corresponding tensorflow::NodeDef*.
void enroll(const TensorName &tensor_name, loco::Node *node)
Registers a name with corresponding loco::Node *.
loco::Node * node(const TensorName &tensor_name) const
Queries enrolled(registered) with name and return node if found Will throw runtime_error if not found...
void enroll(std::unique_ptr< GraphUpdate > &&update)
Registers GraphUpdate objects.
Exception to user.
Definition UserExn.h:42
Definition Log.h:23
FeatureShapeUpdater update(loco::FeatureShape &feature_shape)