Skip to content

Commit

Permalink
[SOT][3.12] Compat for COMPARE_OP arg (#61932)
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo authored Feb 22, 2024
1 parent e047fb8 commit f9593a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,12 @@ def CALL_METHOD(self, instr: Instruction):
push_n=1
) # call instance, in, not in may call TensorVariable.get_py_value, which raise BreakGraphError
def COMPARE_OP(self, instr: Instruction):
op = dis.cmp_op[instr.arg]
cmp_op_index = instr.arg
if sys.version_info >= (3, 12):
# Python 3.12 use lower 4 bits to store the inline cache `jump mask`
# see https://github.com/python/cpython/pull/100924
cmp_op_index >>= 4
op = dis.cmp_op[cmp_op_index]
right, left = self.stack.pop(), self.stack.pop()
self.stack.push(
BuiltinVariable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ def gen_compare(self, cmp_op):
only generator operator instruction, do nothing for
operands.
"""
if sys.version_info >= (3, 12):
cmp_op <<= 4
self._add_instr("COMPARE_OP", cmp_op)

def _add_instr(self, *args, **kwargs):
Expand Down
7 changes: 0 additions & 7 deletions test/sot/skip_files_py312
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
./test_09_f_string.py
./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_20_string.py
./test_21_global.py
./test_analysis_inputs.py
./test_binary_operator_tracker.py
./test_break_graph.py
./test_builtin_map.py
./test_builtin_range.py
./test_builtin_zip.py
./test_dup_top.py
./test_enumerate.py
./test_guard_user_defined_fn.py
./test_inplace_api.py
./test_min_graph_size.py
./test_numpy_var_if.py
./test_output_restoration.py
./test_side_effects.py
./test_simulate_initialize.py
Expand All @@ -29,6 +24,4 @@
./test_sot_resnet50_backward.py
./test_specialization.py
./test_str_format.py
./test_tensor_dtype_in_guard.py
./test_dtype.py
./test_builtin_bool.py

0 comments on commit f9593a5

Please sign in to comment.