mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
[dynamo][guards] Avoid unnecessary stack copies. (#119115)
There is no need to make a `frame_summary_stack` copy in case it's not modified. Proposed change uses copy-on-write functional approach that is easy to understand and is more efficient in case `self.loc_in_frame` is `None` Pull Request resolved: https://github.com/pytorch/pytorch/pull/119115 Approved by: https://github.com/Skylion007
This commit is contained in:
parent
568740f080
commit
2c8722182e
|
|
@ -645,9 +645,9 @@ class TracingContext:
|
|||
self = TracingContext.try_get()
|
||||
if self is None:
|
||||
return traceback.StackSummary()
|
||||
stack = list(self.frame_summary_stack)
|
||||
stack = self.frame_summary_stack
|
||||
if self.loc_in_frame is not None:
|
||||
stack.append(self.loc_in_frame)
|
||||
stack = stack + [self.loc_in_frame]
|
||||
return traceback.StackSummary.from_list(stack)
|
||||
|
||||
# Call this when you want to call into some code that isn't necessarily
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user