mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-27 09:04:53 +08:00
[14/N][Dynamo] Make trace_rules.lookup only handle function + callable type (#118366)
Step by step changes to unblock #118264 Pull Request resolved: https://github.com/pytorch/pytorch/pull/118366 Approved by: https://github.com/angelayi
This commit is contained in:
committed by
PyTorch MergeBot
parent
62c1e4a578
commit
ca1d70632d
@ -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,
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user