Sets the default device for all nodes in graph_def to "device", only if not already set.
| 27 | // Sets the default device for all nodes in graph_def to "device", |
| 28 | // only if not already set. |
| 29 | inline void SetDefaultDevice(const string& device, GraphDef* graph_def) { |
| 30 | for (int i = 0; i < graph_def->node_size(); ++i) { |
| 31 | auto node = graph_def->mutable_node(i); |
| 32 | if (node->device().empty()) { |
| 33 | node->set_device(device); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | } // namespace graph |
| 39 | } // namespace tensorflow |