Skip to content

Commit

Permalink
try to tame more scope crazyness
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi committed Dec 19, 2024
1 parent a08e086 commit edc5343
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions thunder/core/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,14 @@ def insert_inplace(
trc._complete = False

# Creates a temporary scope to record these operations in
old_scope = trc.scopes
scope = []
trc.scopes = [scope]
trc.push_scope(scope)

fn()
_insert_extend_list(trc.bound_symbols, idx, scope)

finally:
trc.scopes = old_scope
trc.pop_scope()
trc._complete = True
reset_tracectx(tracectx_tok)

Expand Down Expand Up @@ -357,16 +356,15 @@ def replace_inplace(
trc._complete = False

# Creates a temporary scope to record these operations in
old_scope = trc.scopes
scope = []
trc.scopes = [scope]
trc.push_scope(scope)

fn(trc.bound_symbols[idx])
del trc.bound_symbols[idx]
_insert_extend_list(trc.bound_symbols, idx, scope)

finally:
trc.scopes = old_scope
trc.pop_scope()
trc._complete = True
reset_tracectx(tracectx_tok)

Expand Down

0 comments on commit edc5343

Please sign in to comment.