Skip to content

Commit

Permalink
fix: changed docstring (#28201)
Browse files Browse the repository at this point in the history
Co-authored-by: ivy-branch <[email protected]>
  • Loading branch information
Adlai-1 and ivy-branch authored Feb 10, 2024
1 parent 3277232 commit e6e72f9
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions ivy/functional/ivy/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,30 +826,47 @@ def default_device(

@handle_exceptions
def set_default_device(device: Union[ivy.Device, ivy.NativeDevice], /) -> None:
"""Set the default device to given device instance.
"""Sets the default device to the argument provided in the function.
Parameters
----------
device
The device to set as the default device
The device to be set as the default device.
Returns
-------
ret
The new default device.
Examples
--------
>>> ivy.set_default_device("cpu")
>>> ivy.default_device()
'cpu'
>>> ivy.set_backend("torch")
>>> ivy.set_default_device("gpu:0")
>>> ivy.default_device(as_native=True)
device(type='cuda', index=0)
>>> ivy.set_backend('jax')
>>> ivy.set_default_device('gpu:0')
>>> ivy.default_device()
'gpu:0'
>>> import torch
>>> ivy.set_backend("torch")
>>> device = torch.device("cuda")
>>> ivy.set_default_device(device)
>>> ivy.default_device(as_native=True)
device(type='cuda')
>>> ivy.set_backend('torch')
>>> ivy.set_default_device('gpu:1')
>>> ivy.default_device()
'gpu:1
>>> ivy.set_backend('tensorflow')
>>> ivy.set_default_device('tpu:0)
>>> ivy.default_device()
'tpu:0
>>> ivy.set_backend('paddle')
>>> ivy.set_default_device('cpu)
>>> ivy.default_device()
'cpu'
>>> ivy.set_backend('mxnet')
>>> ivy.set_default_device('cpu')
>>> ivy.default_device()
'cpu'
"""
global default_device_stack
default_device_stack.append(device)
Expand Down

0 comments on commit e6e72f9

Please sign in to comment.