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

Function ConvertDeviceName

tensorflow/python/eager/pywrap_tensor.cc:170–184  ·  view source on GitHub ↗

Conversion function extracting a const char** device name from a PyObject. The function should be used with PyArg_Parse* APIs.

Source from the content-addressed store, hash-verified

168// Conversion function extracting a const char** device name from a PyObject.
169// The function should be used with PyArg_Parse* APIs.
170int ConvertDeviceName(PyObject* obj, const char** dst) {
171 if (obj == Py_None) {
172 *dst = nullptr;
173 } else {
174 auto device_name = TFE_GetPythonString(obj);
175 if (device_name == nullptr) {
176 PyErr_Clear();
177 PyErr_SetString(PyExc_TypeError, "Error parsing device argument.");
178 return 0;
179 }
180 *dst = device_name;
181 }
182
183 return 1;
184}
185
186} // namespace
187

Callers

nothing calls this directly

Calls 1

TFE_GetPythonStringFunction · 0.85

Tested by

no test coverage detected