mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Fix py opcode (#118977)
Added a C file that includes the symbols _PyOpcode_Deopt and _PyOpcode_Caches since they are not available in the python lib but they are available on Linux in order to fix linking issues in Windows in python 3.11. Fixes #93854 Test by running on python 3.11 `python test/functorch/test_dims.py` Pull Request resolved: https://github.com/pytorch/pytorch/pull/118977 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
b7f898c4a6
commit
247646333e
@ -6,7 +6,7 @@ include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(FT_DIR csrc)
|
||||
file(GLOB_RECURSE FT_SOURCES ${FT_DIR}/*.cpp)
|
||||
file(GLOB_RECURSE FT_SOURCES ${FT_DIR}/*.cpp ${FT_DIR}/*.c)
|
||||
|
||||
add_library(${PROJECT_NAME} MODULE ${FT_SOURCES})
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -1518,14 +1518,14 @@ struct PyInstDecoder {
|
||||
// On Windows, _PyOpcode_Caches and _PyOpcode_Deopt are private symbols
|
||||
// See https://github.com/pytorch/pytorch/issues/93854
|
||||
void next() {
|
||||
#if IS_PYTHON_3_11_PLUS && !defined(_WIN32)
|
||||
#if IS_PYTHON_3_11_PLUS
|
||||
offset_ += _PyOpcode_Caches[opcode()];
|
||||
#endif
|
||||
offset_ += 1;
|
||||
}
|
||||
int opcode() {
|
||||
auto r = _Py_OPCODE(code_[offset_]);
|
||||
#if IS_PYTHON_3_11_PLUS && !defined(_WIN32)
|
||||
#if IS_PYTHON_3_11_PLUS
|
||||
r = _PyOpcode_Deopt[r];
|
||||
#endif
|
||||
return r;
|
||||
|
6
functorch/csrc/dim/dim_opcode.c
Normal file
6
functorch/csrc/dim/dim_opcode.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include <torch/csrc/utils/python_compat.h>
|
||||
#if defined(_WIN32) && IS_PYTHON_3_11_PLUS
|
||||
#define Py_BUILD_CORE
|
||||
#define NEED_OPCODE_TABLES
|
||||
#include "internal/pycore_opcode.h"
|
||||
#endif
|
Reference in New Issue
Block a user