Return true iff we need to add the same device send/recv for 'edge'.
| 112 | |
| 113 | // Return true iff we need to add the same device send/recv for 'edge'. |
| 114 | bool NeedSameDeviceSendRecv(const Edge* edge, const GraphInfo& info) { |
| 115 | if (edge->IsControlEdge()) { |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | const Node* src = edge->src(); |
| 120 | const Node* dst = edge->dst(); |
| 121 | if (src->assigned_device_name() == dst->assigned_device_name()) { |
| 122 | int src_port = edge->src_output(); |
| 123 | int dst_port = edge->dst_input(); |
| 124 | if (info.device_types[src->id()] != DEVICE_CPU) { |
| 125 | auto src_it = info.output_types.find({src->id(), src_port}); |
| 126 | DCHECK(src_it != info.output_types.end()); |
| 127 | auto dst_it = info.input_types.find({dst->id(), dst_port}); |
| 128 | DCHECK(dst_it != info.input_types.end()); |
| 129 | return src_it->second != dst_it->second; |
| 130 | } |
| 131 | } |
| 132 | return false; |
| 133 | } |
| 134 | |
| 135 | // Return true iff (dst, dst_input) is specified on host memory. |
| 136 | bool IsDstInputOnHost(const Edge* edge, const GraphInfo& info) { |
no test coverage detected