MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ParseVisibleDeviceList

Function ParseVisibleDeviceList

tensorflow/compiler/jit/xla_gpu_device.cc:35–54  ·  view source on GitHub ↗

Returns a set containing the device ids contained in visible_device_list or nullopt if it is empty. It returns error in case of malformed configuration string.

Source from the content-addressed store, hash-verified

33// nullopt if it is empty. It returns error in case of malformed configuration
34// string.
35static xla::StatusOr<absl::optional<std::set<int>>> ParseVisibleDeviceList(
36 const string& visible_device_list) {
37 std::set<int> gpu_ids;
38 if (visible_device_list.empty()) {
39 return {{absl::nullopt}};
40 }
41 const std::vector<string> visible_devices =
42 absl::StrSplit(visible_device_list, ',');
43 for (const string& platform_gpu_id_str : visible_devices) {
44 int32 platform_gpu_id;
45 if (!absl::SimpleAtoi(platform_gpu_id_str, &platform_gpu_id)) {
46 return errors::InvalidArgument(
47 "Could not parse entry in 'visible_device_list': '",
48 platform_gpu_id_str,
49 "'. visible_device_list = ", visible_device_list);
50 }
51 gpu_ids.insert(platform_gpu_id);
52 }
53 return {{gpu_ids}};
54}
55
56class XlaGpuDeviceFactory : public DeviceFactory {
57 public:

Callers 1

CreateDevicesMethod · 0.70

Calls 3

InvalidArgumentFunction · 0.85
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected