Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SOT][3.12] Support CALL_INTRINSIC_1 opcode in Python 3.12 #61995

Merged
merged 8 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
gouzil marked this conversation as resolved.
Show resolved Hide resolved
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}")
SigureMo marked this conversation as resolved.
Show resolved Hide resolved


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