Skip to content

Commit

Permalink
remove redundant guard code
Browse files Browse the repository at this point in the history
  • Loading branch information
statelesshz committed Dec 3, 2023
1 parent 0a2970a commit 649dc11
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/accelerate/test_utils/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,7 @@

# This dispatches a defined function according to the hardware accelerator from the function definitions.
def device_agnostic_dispatch(device: str, dispatch_table: Dict[str, Callable], *args, **kwargs):
if device not in dispatch_table:
return dispatch_table["default"](*args, **kwargs)

fn = dispatch_table[device]

# Some device agnostic functions return values. Need to guard against 'None' instead at
# user level
if fn is None:
return None

return fn(*args, **kwargs)
return dispatch_table.get(device, dispatch_table["default"])(*args, **kwargs)


# These are callables which automatically dispatch the function specific to the hardware accelerator
Expand Down

0 comments on commit 649dc11

Please sign in to comment.