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

Function GetCpuClient

tensorflow/compiler/xla/python/cpu_device.cc:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 : Device(id, std::move(local_device_state), kCpuPlatformName) {}
28
29StatusOr<std::shared_ptr<PyLocalClient>> GetCpuClient(bool asynchronous) {
30 TF_ASSIGN_OR_RETURN(se::Platform * platform,
31 PlatformUtil::GetPlatform("Host"));
32 if (platform->VisibleDeviceCount() <= 0) {
33 return FailedPrecondition("CPU platform has no visible devices.");
34 }
35 LocalClientOptions options;
36 options.set_platform(platform);
37 TF_ASSIGN_OR_RETURN(LocalClient * client,
38 ClientLibrary::GetOrCreateLocalClient(options));
39
40 std::vector<std::shared_ptr<Device>> devices;
41 for (int i = 0; i < client->device_count(); ++i) {
42 se::StreamExecutor* executor =
43 client->backend().stream_executor(i).ValueOrDie();
44 auto device_state = absl::make_unique<LocalDeviceState>(
45 executor, client, /*synchronous_deallocation=*/true, asynchronous,
46 /*allow_event_reuse=*/false);
47 std::shared_ptr<Device> device =
48 std::make_shared<CpuDevice>(i, std::move(device_state));
49 devices.push_back(std::move(device));
50 }
51
52 return std::make_shared<PyLocalClient>(
53 kCpuPlatformName, client, std::move(devices), /*host_id=*/0,
54 /*allocator=*/nullptr, /*host_memory_allocator=*/nullptr);
55}
56
57} // namespace xla

Callers

nothing calls this directly

Calls 7

FailedPreconditionFunction · 0.85
stream_executorMethod · 0.80
backendMethod · 0.80
TF_ASSIGN_OR_RETURNFunction · 0.50
VisibleDeviceCountMethod · 0.45
device_countMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected