MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / unpackLong

Function unpackLong

imperative/python/src/utils.cpp:254–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252}
253
254inline int64_t unpackLong(PyObject* obj) {
255 int overflow;
256 long long value = PyLong_AsLongLongAndOverflow(obj, &overflow);
257 if (value == -1 && PyErr_Occurred()) {
258 throw std::runtime_error(
259 "python occur error, maybe the id input is not standard");
260 }
261 if (overflow != 0) {
262 throw std::runtime_error("Overflow when unpacking long");
263 }
264 return (int64_t)value;
265}
266
267static void set_worker_pids(PyObject* id, PyObject* tuple_item) {
268 int64_t key = unpackLong(id);

Callers 2

set_worker_pidsFunction · 0.85
reset_worker_pidsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected