Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changed docstring #28201

Merged
merged 2 commits into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading