xref: /aosp_15_r20/external/pytorch/torch/csrc/dynamo/cpython_defs.h (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #pragma once
2 
3 #include <torch/csrc/utils/python_compat.h>
4 
5 // Functions that need to be copied from the CPython source
6 // should go in cpython_defs.c. Copying is required when, e.g.,
7 // we need to call internal CPython functions that are not exposed.
8 
9 #if IS_PYTHON_3_11_PLUS
10 
11 typedef struct _PyInterpreterFrame _PyInterpreterFrame;
12 
13 int THP_PyFrame_FastToLocalsWithError(
14     _PyInterpreterFrame* frame,
15     int* free_vars_copied);
16 
17 PyFunctionObject* _PyFunction_CopyWithNewCode(
18     PyFunctionObject* o,
19     PyCodeObject* code);
20 
21 void THP_PyFrame_Clear(_PyInterpreterFrame* frame);
22 
23 _PyInterpreterFrame* THP_PyThreadState_BumpFramePointerSlow(
24     PyThreadState* tstate,
25     size_t size);
26 
27 void THP_PyThreadState_PopFrame(
28     PyThreadState* tstate,
29     _PyInterpreterFrame* frame);
30 
31 #endif
32 
33 // pointers to _PyOpcode_Caches for C++
34 #ifdef __cplusplus
35 
36 extern "C" const uint8_t* THP_PyOpcode_Caches;
37 extern "C" const int THP_PyOpcode_Caches_size;
38 
39 #else
40 
41 extern const uint8_t* THP_PyOpcode_Caches;
42 extern const int THP_PyOpcode_Caches_size;
43 
44 #endif
45