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

[docs] add docstring in torch.cuda.get_device_properties #49792

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions torch/cuda/__init__.py
Expand Up @@ -271,6 +271,9 @@ def get_device_name(device: Optional[_device_t] = None) -> str:
name. This function is a no-op if this argument is a negative
integer. It uses the current device, given by :func:`~torch.cuda.current_device`,
if :attr:`device` is ``None`` (default).

Returns:
str: the name of the device
"""
return get_device_properties(device).name

Expand All @@ -293,6 +296,15 @@ def get_device_capability(device: Optional[_device_t] = None) -> Tuple[int, int]


def get_device_properties(device: _device_t) -> _CudaDeviceProperties:
r"""Gets the properties of a device.

Arguments:
ydcjeff marked this conversation as resolved.
Show resolved Hide resolved
ydcjeff marked this conversation as resolved.
Show resolved Hide resolved
device (torch.device or int or str): device for which to return the
properties of the device.

Returns:
_CudaDeviceProperties: the properties of the device
"""
_lazy_init() # will define _get_device_properties
device = _get_device_index(device, optional=True)
if device < 0 or device >= device_count():
Expand Down