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

Method NewDevice

tensorflow/core/common_runtime/device_factory.cc:164–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164std::unique_ptr<Device> DeviceFactory::NewDevice(const string& type,
165 const SessionOptions& options,
166 const string& name_prefix) {
167 auto device_factory = GetFactory(type);
168 if (!device_factory) {
169 return nullptr;
170 }
171 SessionOptions opt = options;
172 (*opt.config.mutable_device_count())[type] = 1;
173 std::vector<std::unique_ptr<Device>> devices;
174 TF_CHECK_OK(device_factory->CreateDevices(opt, name_prefix, &devices));
175 int expected_num_devices = 1;
176 auto iter = options.config.device_count().find(type);
177 if (iter != options.config.device_count().end()) {
178 expected_num_devices = iter->second;
179 }
180 DCHECK_EQ(devices.size(), static_cast<size_t>(expected_num_devices));
181 return std::move(devices[0]);
182}
183
184} // namespace tensorflow

Callers

nothing calls this directly

Calls 5

CreateDevicesMethod · 0.45
findMethod · 0.45
device_countMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected