diff --git a/python/paddle/jit/sot/opcode_translator/executor/instr_flag.py b/python/paddle/jit/sot/opcode_translator/executor/instr_flag.py index 1dd795439d459..448eac6ff95c2 100644 --- a/python/paddle/jit/sot/opcode_translator/executor/instr_flag.py +++ b/python/paddle/jit/sot/opcode_translator/executor/instr_flag.py @@ -13,6 +13,7 @@ # limitations under the License. # flags for instructions +from enum import Enum class FORMAT_VALUE_FLAG: @@ -34,3 +35,19 @@ class MAKE_FUNCTION_FLAG: class CALL_FUNCTION_EX_FLAG: CFE_HAS_KWARGS = 0x01 + + +# see https://github.com/python/cpython/blob/3.12/Python/intrinsics.c#L211-L225 +class IntrinsicsUnaryFunctions(Enum): + INTRINSIC_1_INVALID = 0 + INTRINSIC_PRINT = 1 # no support, only non-interactive mode + INTRINSIC_IMPORT_STAR = 2 # no support, `from module import *` + INTRINSIC_STOPITERATION_ERROR = 3 # no support, generator or coroutine + INTRINSIC_ASYNC_GEN_WRAP = 4 # no support, async + INTRINSIC_UNARY_POSITIVE = 5 + INTRINSIC_LIST_TO_TUPLE = 6 + INTRINSIC_TYPEVAR = 7 # no support, PEP 695 + INTRINSIC_PARAMSPEC = 8 # no support, PEP 695 + INTRINSIC_TYPEVARTUPLE = 9 # no support, PEP 695 + INTRINSIC_SUBSCRIPT_GENERIC = 10 # no support, PEP 695 + INTRINSIC_TYPEALIAS = 11 # no support, PEP 695 diff --git a/python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py b/python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py index 3b40633a73e25..bd4dde84918ff 100644 --- a/python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py +++ b/python/paddle/jit/sot/opcode_translator/executor/opcode_executor.py @@ -62,6 +62,7 @@ CALL_FUNCTION_EX_FLAG as CFE, FORMAT_VALUE_FLAG as FV, MAKE_FUNCTION_FLAG as MF, + IntrinsicsUnaryFunctions, ) from .pycode_generator import PyCodeGen from .tracker import ( @@ -1545,6 +1546,19 @@ def LIST_TO_TUPLE(self, instr: Instruction): ) ) + def CALL_INTRINSIC_1(self, instr: Instruction): + intrinsic_func = IntrinsicsUnaryFunctions(instr.arg) + if intrinsic_func == IntrinsicsUnaryFunctions.INTRINSIC_1_INVALID: + raise RuntimeError("invalid intrinsic function") + elif ( + intrinsic_func == IntrinsicsUnaryFunctions.INTRINSIC_UNARY_POSITIVE + ): + self.UNARY_POSITIVE(instr) + elif intrinsic_func == IntrinsicsUnaryFunctions.INTRINSIC_LIST_TO_TUPLE: + self.LIST_TO_TUPLE(instr) + else: + raise FallbackError(f"No support Intrinsics, {intrinsic_func.name}") + class OpcodeExecutor(OpcodeExecutorBase): """ diff --git a/test/sot/skip_files_py312 b/test/sot/skip_files_py312 index 59cd1a37055f4..92f25948d895e 100644 --- a/test/sot/skip_files_py312 +++ b/test/sot/skip_files_py312 @@ -1,7 +1,5 @@ -./test_10_build_unpack.py ./test_11_jumps.py ./test_12_for_loop.py -./test_14_operators.py ./test_21_global.py ./test_analysis_inputs.py ./test_break_graph.py