Skip to content

Commit

Permalink
Give custom to method a higher priority (NVIDIA#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcarilli authored Jun 18, 2019
1 parent d5e2bb4 commit cd6e46c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apex/amp/_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ def applier(value, fn):
return value
elif isinstance(value, np.ndarray):
return value
elif hasattr(value, "to"): # Allow handling of custom batch classes
return fn(value)
elif isinstance(value, container_abcs.Mapping):
return {applier(k, fn) : applier(v, fn) for k, v in value.items()}
elif isinstance(value, container_abcs.Iterable):
return type(value)(applier(v, fn) for v in value)
elif hasattr(value, "to"): # Allow handling of custom batch classes
return fn(value)
else:
# Do I want this to fire off even if someone chooses to pass something ordinary like
# an int or float? May be more annoying than it's worth.
Expand Down

0 comments on commit cd6e46c

Please sign in to comment.