Skip to content

Commit

Permalink
Make trace_rules.lookup only handle function + callable type (#118366)
Browse files Browse the repository at this point in the history
Summary:
Step by step changes to unblock #118264

X-link: pytorch/pytorch#118366
Approved by: https://github.com/angelayi

Reviewed By: clee2000

Differential Revision: D53171121

Pulled By: yanboliang

fbshipit-source-id: afc55186a795dc7e52906a9f7febc3587fd867d8
  • Loading branch information
yanboliang authored and facebook-github-bot committed Jan 29, 2024
1 parent 05f99ee commit 934f003
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,16 @@ def is_numpy_float_type(value):
)


def is_function_or_wrapper(value):
return (
is_function(value)
or isinstance(value, functools._lru_cache_wrapper)
and is_function(inspect.getattr_static(value, "__wrapped__"))
)


def is_function(value):
return istype(
return isinstance(
value,
(
types.FunctionType,
Expand All @@ -530,6 +538,12 @@ def is_function(value):
)


def unwrap_if_wrapper(value):
if isinstance(value, functools._lru_cache_wrapper):
value = inspect.getattr_static(value, "__wrapped__")
return value


def is_numpy_ndarray(value):
if not np:
return False
Expand Down

0 comments on commit 934f003

Please sign in to comment.