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 all 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 @@ -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 (
Expand Down Expand Up @@ -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):
"""
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_21_global.py
./test_analysis_inputs.py
./test_break_graph.py
Expand Down