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

Function ParseStringValue

tensorflow/python/eager/pywrap_tfe_src.cc:214–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214bool ParseStringValue(const string& key, PyObject* py_value, TF_Status* status,
215 tensorflow::StringPiece* value) {
216 if (PyBytes_Check(py_value)) {
217 Py_ssize_t size = 0;
218 char* buf = nullptr;
219 if (PyBytes_AsStringAndSize(py_value, &buf, &size) < 0) return false;
220 *value = tensorflow::StringPiece(buf, size);
221 return true;
222 }
223#if PY_MAJOR_VERSION >= 3
224 if (PyUnicode_Check(py_value)) {
225 Py_ssize_t size = 0;
226 const char* buf = PyUnicode_AsUTF8AndSize(py_value, &size);
227 if (buf == nullptr) return false;
228 *value = tensorflow::StringPiece(buf, size);
229 return true;
230 }
231#endif
232 TF_SetStatus(
233 status, TF_INVALID_ARGUMENT,
234 tensorflow::strings::StrCat("Expecting a string value for attr ", key,
235 ", got ", py_value->ob_type->tp_name)
236 .c_str());
237 return false;
238}
239
240bool ParseBoolValue(const string& key, PyObject* py_value, TF_Status* status,
241 unsigned char* value) {

Callers 2

SetOpAttrListFunction · 0.85
SetOpAttrScalarFunction · 0.85

Calls 3

TF_SetStatusFunction · 0.85
c_strMethod · 0.80
StrCatFunction · 0.50

Tested by

no test coverage detected