Build memory and device type info for every node in the graph. TODO(yuanbyu): It might be simpler if we convert MemoryType to DeviceType for the inputs/outputs of each node.
| 1191 | // TODO(yuanbyu): It might be simpler if we convert MemoryType to |
| 1192 | // DeviceType for the inputs/outputs of each node. |
| 1193 | Status BuildMemoryDeviceInfo(const Graph& g, GraphInfo* info) { |
| 1194 | MemoryTypeVector input_memory_types; |
| 1195 | MemoryTypeVector output_memory_types; |
| 1196 | |
| 1197 | info->device_types.resize(g.num_node_ids(), DEVICE_CPU); |
| 1198 | for (const Node* node : g.op_nodes()) { |
| 1199 | DeviceNameUtils::ParsedName parsed; |
| 1200 | if (!DeviceNameUtils::ParseFullName(node->assigned_device_name(), |
| 1201 | &parsed)) { |
| 1202 | return errors::Internal("Malformed assigned device '", |
| 1203 | node->assigned_device_name(), "'"); |
| 1204 | } |
| 1205 | |
| 1206 | TF_RETURN_IF_ERROR(MemoryTypesForNode( |
| 1207 | g.op_registry(), DeviceType(parsed.type), node->def(), |
| 1208 | &input_memory_types, &output_memory_types)); |
| 1209 | |
| 1210 | int node_id = node->id(); |
| 1211 | info->device_types[node_id] = DeviceType(parsed.type); |
| 1212 | for (int i = 0; i < input_memory_types.size(); ++i) { |
| 1213 | info->input_types[{node_id, i}] = input_memory_types[i]; |
| 1214 | } |
| 1215 | for (int i = 0; i < output_memory_types.size(); ++i) { |
| 1216 | info->output_types[{node_id, i}] = output_memory_types[i]; |
| 1217 | } |
| 1218 | } |
| 1219 | return Status::OK(); |
| 1220 | } |
| 1221 | |
| 1222 | // Returns in <nodes> the nodes that should participate in epoch-based recv |
| 1223 | // scheduling, along with their times; <nodes> is ordered by increasing |
no test coverage detected