| 149 | } |
| 150 | |
| 151 | DeviceProperties GetDeviceInfo(const DeviceNameUtils::ParsedName& device) { |
| 152 | DeviceProperties unknown; |
| 153 | unknown.set_type("UNKNOWN"); |
| 154 | |
| 155 | if (device.type == "CPU") { |
| 156 | return GetLocalCPUInfo(); |
| 157 | } else if (device.type == "GPU") { |
| 158 | if (device.has_id) { |
| 159 | TfGpuId tf_gpu_id(device.id); |
| 160 | PlatformGpuId platform_gpu_id; |
| 161 | Status s = GpuIdManager::TfToPlatformGpuId(tf_gpu_id, &platform_gpu_id); |
| 162 | if (!s.ok()) { |
| 163 | LOG(ERROR) << s; |
| 164 | return unknown; |
| 165 | } |
| 166 | return GetLocalGPUInfo(platform_gpu_id); |
| 167 | } else { |
| 168 | return GetLocalGPUInfo(PlatformGpuId(0)); |
| 169 | } |
| 170 | } |
| 171 | return unknown; |
| 172 | } |
| 173 | |
| 174 | } // end namespace grappler |
| 175 | } // end namespace tensorflow |