| 27 | namespace { |
| 28 | |
| 29 | TEST(UtilsTest, GetLocalGPUInfo) { |
| 30 | GpuIdManager::TestOnlyReset(); |
| 31 | #if GOOGLE_CUDA |
| 32 | LOG(INFO) << "CUDA is enabled."; |
| 33 | DeviceProperties properties; |
| 34 | |
| 35 | // Invalid platform GPU ID. |
| 36 | properties = GetLocalGPUInfo(PlatformGpuId(100)); |
| 37 | EXPECT_EQ("UNKNOWN", properties.type()); |
| 38 | |
| 39 | // Succeed when a valid platform GPU id was inserted. |
| 40 | properties = GetLocalGPUInfo(PlatformGpuId(0)); |
| 41 | EXPECT_EQ("GPU", properties.type()); |
| 42 | EXPECT_EQ("NVIDIA", properties.vendor()); |
| 43 | #elif TENSORFLOW_USE_ROCM |
| 44 | LOG(INFO) << "ROCm is enabled."; |
| 45 | DeviceProperties properties; |
| 46 | |
| 47 | // Invalid platform GPU ID. |
| 48 | properties = GetLocalGPUInfo(PlatformGpuId(100)); |
| 49 | EXPECT_EQ("UNKNOWN", properties.type()); |
| 50 | |
| 51 | // Succeed when a valid platform GPU id was inserted. |
| 52 | properties = GetLocalGPUInfo(PlatformGpuId(0)); |
| 53 | EXPECT_EQ("GPU", properties.type()); |
| 54 | EXPECT_EQ("Advanced Micro Devices, Inc", properties.vendor()); |
| 55 | #else |
| 56 | LOG(INFO) << "CUDA is not enabled."; |
| 57 | DeviceProperties properties; |
| 58 | |
| 59 | properties = GetLocalGPUInfo(PlatformGpuId(0)); |
| 60 | EXPECT_EQ("GPU", properties.type()); |
| 61 | |
| 62 | properties = GetLocalGPUInfo(PlatformGpuId(100)); |
| 63 | EXPECT_EQ("GPU", properties.type()); |
| 64 | #endif |
| 65 | } |
| 66 | |
| 67 | TEST(UtilsTest, GetDeviceInfo) { |
| 68 | GpuIdManager::TestOnlyReset(); |
nothing calls this directly
no test coverage detected