pytorch/torch/_C/_VariableFunctions.pyi.in
Brian Vaughan dbb96ef30d improve annotation device parameters where a device ordinal is allowed (#113647)
Using mypy in code that depends on pytorch, I noticed that the type annotation doesn't allow a device ordinal.

`error: Argument "device" to "to_empty" of "Module" has incompatible type "int"; expected "str | device"  [arg-type]`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/113647
Approved by: https://github.com/albanD
2023-11-17 14:41:22 +00:00

41 lines
589 B
Python

# ${generated_comment}
import builtins
from typing import (
Any,
Callable,
ContextManager,
Iterator,
List,
Literal,
NamedTuple,
Optional,
overload,
Sequence,
Tuple,
TypeVar,
Union,
)
import torch
from torch import contiguous_format, Generator, inf, memory_format, strided, SymInt, Tensor
from torch.types import (
_bool,
_complex,
_device,
_dtype,
_float,
_int,
_layout,
_qscheme,
_size,
Device,
Number,
)
from torch._prims_common import DeviceLikeType
${function_hints}
${all_directive}