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

Function LookupDevice

tensorflow/core/common_runtime/graph_execution_state.cc:351–379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349
350template <class Map>
351Status LookupDevice(const DeviceSet& device_set, const string& tensor_name,
352 const Map& tensor2device,
353 const tensorflow::DeviceAttributes** out_device_attrs) {
354 *out_device_attrs = nullptr;
355 if (tensor2device.empty()) {
356 *out_device_attrs = &device_set.client_device()->attributes();
357 return Status::OK();
358 }
359 const auto it = tensor2device.find(tensor_name);
360 if (it == tensor2device.end()) {
361 *out_device_attrs = &device_set.client_device()->attributes();
362 return Status::OK();
363 }
364 DeviceNameUtils::ParsedName parsed_name;
365 if (!DeviceNameUtils::ParseFullName(it->second, &parsed_name)) {
366 return errors::InvalidArgument("Invalid device name ('", it->second,
367 "') provided for the tensor '", tensor_name,
368 "' in CallableOptions");
369 }
370 Device* device = device_set.FindDeviceByName(
371 DeviceNameUtils::ParsedNameToString(parsed_name));
372 if (device == nullptr) {
373 return errors::InvalidArgument("Device '", it->second,
374 "' specified for tensor '", tensor_name,
375 "' in CallableOptions does not exist");
376 }
377 *out_device_attrs = &device->attributes();
378 return Status::OK();
379}
380
381struct TensorAndDevice {
382 // WARNING: backing memory for the 'tensor' field is NOT owend.

Callers 1

PruneGraphMethod · 0.70

Calls 6

InvalidArgumentFunction · 0.85
client_deviceMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
FindDeviceByNameMethod · 0.45

Tested by

no test coverage detected