| 101 | } |
| 102 | |
| 103 | NodeDef* AddNode(StringPiece name, StringPiece op, |
| 104 | const std::vector<string>& inputs, |
| 105 | const std::vector<std::pair<string, AttrValue>>& attributes, |
| 106 | MutableGraphView* graph) { |
| 107 | NodeDef node; |
| 108 | if (!name.empty()) { |
| 109 | node.set_name(string(name)); |
| 110 | } else { |
| 111 | SetUniqueGraphNodeName(op, graph->graph(), &node); |
| 112 | } |
| 113 | node.set_op(string(op)); |
| 114 | for (const string& input : inputs) { |
| 115 | node.add_input(input); |
| 116 | } |
| 117 | for (auto attr : attributes) { |
| 118 | (*node.mutable_attr())[attr.first] = attr.second; |
| 119 | } |
| 120 | return graph->AddNode(std::move(node)); |
| 121 | } |
| 122 | |
| 123 | template <> |
| 124 | NodeDef* AddScalarConstNode(bool v, MutableGraphView* graph) { |