Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
feifei-111 committed Oct 8, 2023
1 parent e2effa4 commit 9f0cd4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions sot/opcode_translator/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ def eval_frame_callback(frame, **kwargs) -> CustomCode:
used_code = custom_code.code

# just check those codes which need open eval_frame
if custom_code.disable_eval_frame is False and CodeStatus().check_code(
used_code
if (
custom_code.disable_eval_frame is False
and CodeStatus().is_code_without_graph(used_code)
):
log(
3,
Expand Down
19 changes: 9 additions & 10 deletions sot/utils/code_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def clear(self):
self.code_map.clear()
self.setup_code_map()

def check_code(self, code):
def is_code_without_graph(self, code):
if code not in self.code_map:
info = CodeInfo()
self.code_map[code] = info
Expand All @@ -51,17 +51,16 @@ def check_code(self, code):

if info.state == CodeState.WITHOUT_GRAPH:
return True
elif info.state == CodeState.UNKNOW:
self.visit(code)
if info.state == CodeState.UNKNOW:
info.counter += 1
if info.counter >= 10:
log(
3,
f"[CodeStatus] Switch state to WITHOUT_GRAPH for {code}\n",
)
info.state = CodeState.WITHOUT_GRAPH
return False

def visit(self, code):
info = self.code_map[code]
info.counter += 1
if info.counter >= 10:
log(3, f"[CodeStatus] Switch state to WITHOUT_GRAPH for {code}\n")
info.state = CodeState.WITHOUT_GRAPH

def trace_back_frames(self):
frame = inspect.currentframe()
while frame.f_back is not None:
Expand Down
File renamed without changes.

0 comments on commit 9f0cd4b

Please sign in to comment.