Skip to content

Commit

Permalink
cache the hash construction on Guard (#110464)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#110464
Approved by: https://github.com/zou3519, https://github.com/voznesenskym

Reviewed By: PaliC

Differential Revision: D49921897

Pulled By: Chillee

fbshipit-source-id: 3bef469e24debf7880a8f2d2e929364f1dd6cd9b
  • Loading branch information
Chillee authored and facebook-github-bot committed Oct 5, 2023
1 parent d60771c commit 6bc2b07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ def tabulate(rows, headers):
)


def dynamo_profiled(func):
CPROFILE_ENABLED = False


def cprofile_wrapper(func):
@wraps(func)
def profile_wrapper(*args, **kwargs):
global timer_counter
global timer_counter, CPROFILE_ENABLED
CPROFILE_ENABLED = True
datafn = (
func.__name__ + f"{next(timer_counter)}.profile"
) # Name the data file sensibly
Expand Down Expand Up @@ -181,8 +185,13 @@ def print_time_report():
# phase_names record an extra record into a separate compilation timing structure,
# one keyed on frame+name rather than function.
# The frame is incremented outside of this function, in def increment_frame() above.


def dynamo_timed(original_function=None, phase_name=None):
def dynamo_timed_inner(func):
if CPROFILE_ENABLED:
return func

@wraps(func)
def time_wrapper(*args, **kwargs):
key = func.__qualname__
Expand Down

0 comments on commit 6bc2b07

Please sign in to comment.