Skip to content

Commit

Permalink
Replace PyLong_From with THPUtils_packUInt() to avoid overflow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
razarmehr committed May 24, 2023
1 parent 539fac5 commit 944f2df
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torch/csrc/mps/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static PyObject* MPSModule_currentAllocatedMemory(
PyObject* _unused,
PyObject* noargs) {
HANDLE_TH_ERRORS
return PyLong_FromUnsignedLongLong(
return THPUtils_packUInt64(
at::detail::getMPSHooks().getCurrentAllocatedMemory());
END_HANDLE_TH_ERRORS
}
Expand All @@ -114,7 +114,7 @@ static PyObject* MPSModule_driverAllocatedMemory(
PyObject* _unused,
PyObject* noargs) {
HANDLE_TH_ERRORS
return PyLong_FromUnsignedLongLong(
return THPUtils_packUInt64(
at::detail::getMPSHooks().getDriverAllocatedMemory());
END_HANDLE_TH_ERRORS
}
Expand Down Expand Up @@ -149,7 +149,7 @@ static PyObject* MPSModule_profilerStopTrace(
static PyObject* MPSModule_acquireEvent(PyObject* _unused, PyObject* args) {
HANDLE_TH_ERRORS
const bool enable_timing = THPUtils_unpackBool(args);
return PyLong_FromUnsignedLong(
return THPUtils_packUInt32(
at::detail::getMPSHooks().acquireEvent(enable_timing));
END_HANDLE_TH_ERRORS
}
Expand Down

0 comments on commit 944f2df

Please sign in to comment.