Skip to content

Commit

Permalink
[docs] add docstring in torch.cuda.get_device_properties (#49792)
Browse files Browse the repository at this point in the history
Summary:
Fixes #49737

Added docstring in `torch.cuda.get_device_properties`
Added the `Returns` in `torch.cuda.get_device_name`

Pull Request resolved: #49792

Reviewed By: mruberry

Differential Revision: D25784046

Pulled By: ngimel

fbshipit-source-id: f88da02147f92c889398957fcaf22961d3bb1062
  • Loading branch information
Jeff Yang authored and facebook-github-bot committed Jan 5, 2021
1 parent abe1fa4 commit d1a56fc
Showing 1 changed file with 12 additions and 0 deletions.
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.
Args:
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

0 comments on commit d1a56fc

Please sign in to comment.