Skip to content
17 changes: 17 additions & 0 deletions python/paddle/jit/sot/opcode_translator/executor/instr_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

# flags for instructions
from enum import Enum


class FORMAT_VALUE_FLAG:
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,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 (
Expand Down Expand Up @@ -1493,6 +1494,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
):
return self.UNARY_POSITIVE(instr)
elif Intrinsic_Func == IntrinsicsUnaryFunctions.INTRINSIC_LIST_TO_TUPLE:
return self.LIST_TO_TUPLE(instr)
else:
raise FallbackError(f"No support Intrinsics, {Intrinsic_Func.name}")


class OpcodeExecutor(OpcodeExecutorBase):
"""
Expand Down
2 changes: 0 additions & 2 deletions test/sot/skip_files_py312
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
./test_10_build_unpack.py
./test_11_jumps.py
./test_12_for_loop.py
./test_14_operators.py
./test_15_slice.py
./test_17_paddle_layer.py
./test_21_global.py
Expand Down