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

Function GetDeviceName

tensorflow/c/eager/c_api_test_util.cc:207–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207bool GetDeviceName(TFE_Context* ctx, string* device_name,
208 const char* device_type) {
209 std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> status(
210 TF_NewStatus(), TF_DeleteStatus);
211 TF_DeviceList* devices = TFE_ContextListDevices(ctx, status.get());
212 CHECK_EQ(TF_OK, TF_GetCode(status.get())) << TF_Message(status.get());
213
214 const int num_devices = TF_DeviceListCount(devices);
215 for (int i = 0; i < num_devices; ++i) {
216 const string dev_type(TF_DeviceListType(devices, i, status.get()));
217 CHECK_EQ(TF_GetCode(status.get()), TF_OK) << TF_Message(status.get());
218 const string dev_name(TF_DeviceListName(devices, i, status.get()));
219 CHECK_EQ(TF_GetCode(status.get()), TF_OK) << TF_Message(status.get());
220 if (dev_type == device_type) {
221 *device_name = dev_name;
222 LOG(INFO) << "Found " << device_type << " device " << *device_name;
223 TF_DeleteDeviceList(devices);
224 return true;
225 }
226 }
227 TF_DeleteDeviceList(devices);
228 return false;
229}

Callers 7

TensorHandleSilentCopyFunction · 0.70
SetAndGetOpDevicesFunction · 0.70
TESTFunction · 0.70
ExecuteWithProfilingFunction · 0.70

Calls 7

TF_NewStatusFunction · 0.85
TFE_ContextListDevicesFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TF_DeviceListCountFunction · 0.85
TF_DeleteDeviceListFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected