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

Method PyLocalClient

tensorflow/compiler/xla/python/local_client.cc:114–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114PyLocalClient::PyLocalClient(
115 std::string platform_name, LocalClient* client,
116 std::vector<std::shared_ptr<Device>> devices, int host_id,
117 std::unique_ptr<se::DeviceMemoryAllocator> allocator,
118 std::unique_ptr<tensorflow::Allocator> host_memory_allocator)
119 : platform_name_(std::move(platform_name)),
120 client_(client),
121 devices_(std::move(devices)),
122 host_id_(host_id),
123 owned_allocator_(std::move(allocator)),
124 host_memory_allocator_(std::move(host_memory_allocator)),
125 h2d_transfer_pool_(tensorflow::Env::Default(), "py_xla_h2d_transfer",
126 client->device_count()) {
127 if (owned_allocator_ != nullptr) {
128 allocator_ = owned_allocator_.get();
129 } else {
130 allocator_ = client_->backend().memory_allocator();
131 }
132
133 for (const std::shared_ptr<Device>& device : devices_) {
134 CHECK(id_to_device_.insert({device->id(), device}).second)
135 << "Duplicate device id: " << device->id();
136
137 if (device->local_device_state()) {
138 int idx = device->local_device_state()->device_ordinal();
139 if (idx >= local_devices_.size()) {
140 local_devices_.resize(idx + 1);
141 }
142 CHECK(local_devices_[idx] == nullptr) << idx;
143 local_devices_[idx] = device;
144 }
145 }
146 for (int idx = 0; idx < local_devices_.size(); ++idx) {
147 CHECK(local_devices_[idx] != nullptr) << idx;
148 }
149}
150
151StatusOr<DeviceAssignment> PyLocalClient::GetDefaultDeviceAssignment(
152 int num_replicas, int num_partitions) const {

Callers

nothing calls this directly

Calls 11

DefaultFunction · 0.85
backendMethod · 0.80
local_device_stateMethod · 0.80
device_countMethod · 0.45
getMethod · 0.45
memory_allocatorMethod · 0.45
insertMethod · 0.45
idMethod · 0.45
device_ordinalMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected