mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Remove code for Python < 3.9 (#147181)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/147181 Approved by: https://github.com/albanD
This commit is contained in:
parent
9919375cf1
commit
8daa742e8b
|
|
@ -864,9 +864,9 @@ if(NOT Python_Interpreter_FOUND)
|
|||
message(FATAL_ERROR "Python3 could not be found.")
|
||||
endif()
|
||||
|
||||
if(${Python_VERSION} VERSION_LESS 3.8)
|
||||
if(${Python_VERSION} VERSION_LESS 3.9)
|
||||
message(FATAL_ERROR
|
||||
"Found Python libraries version ${Python_VERSION}. Python < 3.8 is no longer supported by PyTorch.")
|
||||
"Found Python libraries version ${Python_VERSION}. Python < 3.9 is no longer supported by PyTorch.")
|
||||
endif()
|
||||
|
||||
# ---[ Python + Numpy
|
||||
|
|
|
|||
|
|
@ -58,14 +58,9 @@ extern "C" {
|
|||
inline _PyFrameEvalFunction _debug_set_eval_frame(
|
||||
PyThreadState* tstate,
|
||||
_PyFrameEvalFunction eval_frame) {
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
_PyFrameEvalFunction prev =
|
||||
_PyInterpreterState_GetEvalFrameFunc(tstate->interp);
|
||||
_PyInterpreterState_SetEvalFrameFunc(tstate->interp, eval_frame);
|
||||
#else
|
||||
_PyFrameEvalFunction prev = tstate->interp->eval_frame;
|
||||
tstate->interp->eval_frame = eval_frame;
|
||||
#endif
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,27 +205,17 @@ static PyObject* (*previous_eval_frame)(
|
|||
THP_EVAL_API_FRAME_OBJECT* frame,
|
||||
int throw_flag) = NULL;
|
||||
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
static PyObject* dynamo_custom_eval_frame_shim(
|
||||
PyThreadState* tstate,
|
||||
THP_EVAL_API_FRAME_OBJECT* frame,
|
||||
int throw_flag) {
|
||||
return dynamo__custom_eval_frame_shim(tstate, frame, throw_flag);
|
||||
}
|
||||
#else
|
||||
static PyObject* dynamo_custom_eval_frame_shim(
|
||||
THP_EVAL_API_FRAME_OBJECT* frame,
|
||||
int throw_flag) {
|
||||
PyThreadState* tstate = PyThreadState_GET();
|
||||
return dynamo__custom_eval_frame_shim(tstate, frame, throw_flag);
|
||||
}
|
||||
#endif
|
||||
|
||||
static PyObject* dynamo_eval_frame_default(
|
||||
PyThreadState* tstate,
|
||||
THP_EVAL_API_FRAME_OBJECT* frame,
|
||||
int throw_flag) {
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
if (tstate == NULL) {
|
||||
tstate = PyThreadState_GET();
|
||||
}
|
||||
|
|
@ -234,13 +224,9 @@ static PyObject* dynamo_eval_frame_default(
|
|||
} else {
|
||||
return _PyEval_EvalFrameDefault(tstate, frame, throw_flag);
|
||||
}
|
||||
#else
|
||||
return _PyEval_EvalFrameDefault(frame, throw_flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void enable_eval_frame_shim(PyThreadState* tstate) {
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
if (_PyInterpreterState_GetEvalFrameFunc(tstate->interp) !=
|
||||
&dynamo_custom_eval_frame_shim) {
|
||||
DEBUG_CHECK(previous_eval_frame == NULL);
|
||||
|
|
@ -248,28 +234,15 @@ static void enable_eval_frame_shim(PyThreadState* tstate) {
|
|||
_PyInterpreterState_SetEvalFrameFunc(
|
||||
tstate->interp, &dynamo_custom_eval_frame_shim);
|
||||
}
|
||||
#else
|
||||
if (tstate->interp->eval_frame != &custom_eval_frame_shim) {
|
||||
// First call
|
||||
tstate->interp->eval_frame = &custom_eval_frame_shim;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void enable_eval_frame_default(PyThreadState* tstate) {
|
||||
#if PY_VERSION_HEX >= 0x03090000
|
||||
if (_PyInterpreterState_GetEvalFrameFunc(tstate->interp) !=
|
||||
previous_eval_frame) {
|
||||
DEBUG_CHECK(previous_eval_frame != NULL);
|
||||
_PyInterpreterState_SetEvalFrameFunc(tstate->interp, previous_eval_frame);
|
||||
previous_eval_frame = NULL;
|
||||
}
|
||||
#else
|
||||
if (tstate->interp->eval_frame != &_PyEval_EvalFrameDefault) {
|
||||
// First call
|
||||
tstate->interp->eval_frame = &_PyEval_EvalFrameDefault;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char* get_frame_name(THP_EVAL_API_FRAME_OBJECT* frame) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user