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

Function ConvertOneInt64

tensorflow/python/lib/core/py_seq_tensor.cc:292–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290// Int support
291
292const char* ConvertOneInt64(PyObject* v, int64* out) {
293#if PY_MAJOR_VERSION < 3
294 if (TF_PREDICT_TRUE(PyInt_Check(v))) {
295 *out = PyInt_AS_LONG(v);
296 return nullptr;
297 }
298#endif
299 if (TF_PREDICT_TRUE(PyLong_Check(v) || IsPyDimension(v))) {
300 int overflow = 0;
301 // Have to use LongLong for 64 bits, since long is 32 bits on Windows.
302 *out = PyLong_AsLongLongAndOverflow(v, &overflow);
303 if (TF_PREDICT_FALSE(overflow)) return ErrorOutOfRange;
304 return nullptr;
305 }
306 if (PyIsInstance(v, &PyIntegerArrType_Type)) { // NumPy integers
307#if PY_MAJOR_VERSION < 3
308 Safe_PyObjectPtr as_int = make_safe(PyNumber_Int(v));
309#else
310 Safe_PyObjectPtr as_int = make_safe(PyNumber_Long(v));
311#endif
312 return ConvertOneInt64(as_int.get(), out);
313 }
314 if (IsPyFloat(v)) return ErrorFoundFloat;
315 return ErrorMixedTypes;
316}
317
318DEFINE_HELPER(ConvertInt64, int64, DT_INT64, ConvertOneInt64);
319

Callers

nothing calls this directly

Calls 5

IsPyDimensionFunction · 0.85
PyIsInstanceFunction · 0.85
IsPyFloatFunction · 0.85
make_safeFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected