Skip to content

Commit

Permalink
Refactor out TorchInGraphFunctionVariable and improve heuristic (#113…
Browse files Browse the repository at this point in the history
…432)

Summary:
This is splitted from #113009, please check pytorch/pytorch#113009 (comment) for more details.

X-link: pytorch/pytorch#113432
Approved by: https://github.com/ezyang, https://github.com/jansel

Reviewed By: osalpekar

Differential Revision: D52017969

Pulled By: yanboliang

fbshipit-source-id: 0430cf5428cf086616f6290db3cf3cb065f0938d
  • Loading branch information
yanboliang authored and facebook-github-bot committed Dec 12, 2023
1 parent fd78d61 commit f8f3aec
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,19 @@ def is_numpy_float_type(value):
)


def is_function(value):
return istype(
value,
(
types.FunctionType,
types.MethodType,
types.BuiltinFunctionType,
types.MethodDescriptorType,
types.WrapperDescriptorType,
),
)


def is_numpy_ndarray(value):
if not np:
return False
Expand Down Expand Up @@ -2268,11 +2281,14 @@ def get_static_address_type(t):

def is_rng_state_getter_or_setter(value):
getters = (
# The following two functions are not identical, so don't remove anyone!
torch._C.Generator.get_state,
torch.default_generator.get_state,
torch.get_rng_state,
torch.cuda.get_rng_state,
)
setters = (
torch._C.Generator.set_state,
torch.default_generator.set_state,
torch.set_rng_state,
torch.cuda.set_rng_state,
Expand Down

0 comments on commit f8f3aec

Please sign in to comment.