pyrefly-torch-stubs 1.4.0.dev3__tar.gz → 1.4.0.dev4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/PKG-INFO +6 -3
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/README.md +3 -1
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/pyproject.toml +3 -2
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/__init__.pyi +131 -49
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/_shapes.pyi +294 -37
- pyrefly_torch_stubs-1.4.0.dev4/torch-stubs/distributions/constraints.pyi +234 -0
- pyrefly_torch_stubs-1.4.0.dev4/torch-stubs/distributions/transforms.pyi +149 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/fft.pyi +94 -9
- pyrefly_torch_stubs-1.4.0.dev4/torch-stubs/linalg.pyi +490 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/__init__.pyi +8 -5
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/attention/__init__.pyi +6 -4
- pyrefly_torch_stubs-1.4.0.dev4/torch-stubs/nn/attention/flex_attention.pyi +143 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/functional.pyi +1079 -39
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/init.pyi +24 -5
- pyrefly_torch_stubs-1.4.0.dev4/torch-stubs/return_types.pyi +190 -0
- pyrefly_torch_stubs-1.4.0.dev3/torch-stubs/distributions/constraints.pyi +0 -48
- pyrefly_torch_stubs-1.4.0.dev3/torch-stubs/distributions/transforms.pyi +0 -46
- pyrefly_torch_stubs-1.4.0.dev3/torch-stubs/linalg.pyi +0 -138
- pyrefly_torch_stubs-1.4.0.dev3/torch-stubs/nn/attention/flex_attention.pyi +0 -78
- pyrefly_torch_stubs-1.4.0.dev3/torch-stubs/return_types.pyi +0 -89
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/LICENSE +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/test/README.md +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/_tensor.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/distributions/__init__.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/distributions/beta.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/distributions/categorical.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/distributions/transformed_distribution.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/modules/__init__.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/modules/module.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/nn/parameter.pyi +0 -0
- {pyrefly_torch_stubs-1.4.0.dev3 → pyrefly_torch_stubs-1.4.0.dev4}/torch-stubs/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyrefly-torch-stubs
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev4
|
|
4
4
|
Summary: PyTorch type stubs with tensor-shape tracking, maintained by Pyrefly
|
|
5
5
|
Project-URL: homepage, https://pyrefly.org
|
|
6
6
|
Project-URL: documentation, https://pyrefly.org/en/docs/
|
|
@@ -33,7 +33,8 @@ Classifier: Programming Language :: Python
|
|
|
33
33
|
Classifier: Programming Language :: Python :: 3
|
|
34
34
|
Classifier: Typing :: Stubs Only
|
|
35
35
|
Requires-Python: >=3.10
|
|
36
|
-
Requires-Dist: pyrefly-shape-extensions==1.4.0.
|
|
36
|
+
Requires-Dist: pyrefly-shape-extensions==1.4.0.dev4
|
|
37
|
+
Requires-Dist: torch
|
|
37
38
|
Description-Content-Type: text/markdown
|
|
38
39
|
|
|
39
40
|
# pyrefly-torch-stubs
|
|
@@ -45,7 +46,9 @@ This package is a PEP 561 stub-only distribution. It installs the
|
|
|
45
46
|
runtime `torch` package without replacing or shadowing PyTorch itself.
|
|
46
47
|
|
|
47
48
|
The package is versioned in lockstep with Pyrefly and depends on the matching
|
|
48
|
-
`pyrefly-shape-extensions` package.
|
|
49
|
+
`pyrefly-shape-extensions` package. Installing it also installs `torch`, which
|
|
50
|
+
provides upstream modules used by these partial stubs. The `torch` dependency is
|
|
51
|
+
unpinned, so projects can choose their own PyTorch version.
|
|
49
52
|
|
|
50
53
|
Static checks use the installed Torch package for modules that this package
|
|
51
54
|
intentionally leaves unshaped:
|
|
@@ -7,7 +7,9 @@ This package is a PEP 561 stub-only distribution. It installs the
|
|
|
7
7
|
runtime `torch` package without replacing or shadowing PyTorch itself.
|
|
8
8
|
|
|
9
9
|
The package is versioned in lockstep with Pyrefly and depends on the matching
|
|
10
|
-
`pyrefly-shape-extensions` package.
|
|
10
|
+
`pyrefly-shape-extensions` package. Installing it also installs `torch`, which
|
|
11
|
+
provides upstream modules used by these partial stubs. The `torch` dependency is
|
|
12
|
+
unpinned, so projects can choose their own PyTorch version.
|
|
11
13
|
|
|
12
14
|
Static checks use the installed Torch package for modules that this package
|
|
13
15
|
intentionally leaves unshaped:
|
|
@@ -8,7 +8,7 @@ description = "PyTorch type stubs with tensor-shape tracking, maintained by Pyre
|
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
requires-python = ">=3.10"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
11
|
-
version = "1.4.0.
|
|
11
|
+
version = "1.4.0.dev4"
|
|
12
12
|
keywords = ["typechecker", "typechecking", "stubs", "torch", "pytorch"]
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Development Status :: 4 - Beta",
|
|
@@ -18,7 +18,8 @@ classifiers = [
|
|
|
18
18
|
"Typing :: Stubs Only",
|
|
19
19
|
]
|
|
20
20
|
dependencies = [
|
|
21
|
-
"pyrefly-shape-extensions==1.4.0.
|
|
21
|
+
"pyrefly-shape-extensions==1.4.0.dev4",
|
|
22
|
+
"torch",
|
|
22
23
|
]
|
|
23
24
|
|
|
24
25
|
[project.urls]
|
|
@@ -621,6 +621,7 @@ from torch._shapes import (
|
|
|
621
621
|
repeat_shape,
|
|
622
622
|
replace_axis_extent,
|
|
623
623
|
reshape_shape,
|
|
624
|
+
reverse_shape,
|
|
624
625
|
scatter_shape,
|
|
625
626
|
select_shape,
|
|
626
627
|
size_dim_shape,
|
|
@@ -665,6 +666,7 @@ from torch.random import (
|
|
|
665
666
|
thread_safe_generator as thread_safe_generator,
|
|
666
667
|
)
|
|
667
668
|
from torch.storage import TypedStorage as TypedStorage, UntypedStorage as UntypedStorage
|
|
669
|
+
from typing_extensions import TypeIs
|
|
668
670
|
|
|
669
671
|
if TYPE_CHECKING:
|
|
670
672
|
from shape_extensions import Int as _Int
|
|
@@ -682,7 +684,7 @@ type _BasicIndex = builtins.int | slice | list[builtins.int] | None | EllipsisTy
|
|
|
682
684
|
type _TensorScalar = builtins.bool | builtins.int | builtins.float | builtins.complex
|
|
683
685
|
type _LegacyTensorScalar = builtins.bool | builtins.int | builtins.float
|
|
684
686
|
|
|
685
|
-
# Dtype constants
|
|
687
|
+
# Dtype and memory-format constants
|
|
686
688
|
qint8: Any
|
|
687
689
|
quint8: Any
|
|
688
690
|
float16: Any
|
|
@@ -692,8 +694,10 @@ int8: Any
|
|
|
692
694
|
int16: Any
|
|
693
695
|
int32: Any
|
|
694
696
|
int64: Any
|
|
697
|
+
uint8: Any
|
|
695
698
|
int: Any
|
|
696
699
|
bool: Any
|
|
700
|
+
channels_last: memory_format
|
|
697
701
|
ops: Any
|
|
698
702
|
|
|
699
703
|
# ============================================================================
|
|
@@ -754,7 +758,8 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
754
758
|
device: Any # Device where tensor is stored (cpu, cuda, etc.)
|
|
755
759
|
dtype: Any # Data type of tensor elements (float32, int64, etc.)
|
|
756
760
|
ndim: builtins.int # Number of dimensions
|
|
757
|
-
|
|
761
|
+
@property
|
|
762
|
+
def T(self: Tensor[Shape]) -> Tensor[reverse_shape(Shape)]: ...
|
|
758
763
|
real: Self # Real part of complex tensor (shape-preserving)
|
|
759
764
|
imag: Self # Imaginary part of complex tensor (shape-preserving)
|
|
760
765
|
|
|
@@ -892,18 +897,12 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
892
897
|
|
|
893
898
|
# ==== Comparison Operations ====
|
|
894
899
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
self, other: Tensor[OtherShape]
|
|
900
|
+
def __eq__[OtherShape: _Shape = []](
|
|
901
|
+
self, other: _TensorLike[OtherShape]
|
|
898
902
|
) -> Tensor[broadcast(Shape, OtherShape)]: ... # type: ignore[override]
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
@overload
|
|
902
|
-
def __ne__[OtherShape: _Shape](
|
|
903
|
-
self, other: Tensor[OtherShape]
|
|
903
|
+
def __ne__[OtherShape: _Shape = []](
|
|
904
|
+
self, other: _TensorLike[OtherShape]
|
|
904
905
|
) -> Tensor[broadcast(Shape, OtherShape)]: ... # type: ignore[override]
|
|
905
|
-
@overload
|
|
906
|
-
def __ne__(self, other: builtins.float | builtins.int) -> Self: ... # type: ignore[override]
|
|
907
906
|
# Ordering results are gradual because they are tensors elementwise, but
|
|
908
907
|
# scalar tensors are also valid in truth-valued comparison protocols.
|
|
909
908
|
def __lt__(self, other: Tensor | builtins.float | builtins.int) -> Any: ...
|
|
@@ -916,24 +915,15 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
916
915
|
# comparison operators do. Combining masks with `&` and `|` is the common
|
|
917
916
|
# case, and those masks come from the comparisons above.
|
|
918
917
|
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
self, other: Tensor[OtherShape]
|
|
918
|
+
def __and__[OtherShape: _Shape = []](
|
|
919
|
+
self, other: _IntegerTensorLike[OtherShape]
|
|
922
920
|
) -> Tensor[broadcast(Shape, OtherShape)]: ...
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
@overload
|
|
926
|
-
def __or__[OtherShape: _Shape](
|
|
927
|
-
self, other: Tensor[OtherShape]
|
|
921
|
+
def __or__[OtherShape: _Shape = []](
|
|
922
|
+
self, other: _IntegerTensorLike[OtherShape]
|
|
928
923
|
) -> Tensor[broadcast(Shape, OtherShape)]: ...
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
@overload
|
|
932
|
-
def __xor__[OtherShape: _Shape](
|
|
933
|
-
self, other: Tensor[OtherShape]
|
|
924
|
+
def __xor__[OtherShape: _Shape = []](
|
|
925
|
+
self, other: _IntegerTensorLike[OtherShape]
|
|
934
926
|
) -> Tensor[broadcast(Shape, OtherShape)]: ...
|
|
935
|
-
@overload
|
|
936
|
-
def __xor__(self, other: bool | int) -> Self: ...
|
|
937
927
|
def __rand__(self, other: bool | int) -> Self: ...
|
|
938
928
|
def __ror__(self, other: bool | int) -> Self: ...
|
|
939
929
|
def __rxor__(self, other: bool | int) -> Self: ...
|
|
@@ -1675,22 +1665,26 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
1675
1665
|
"""Compute distance to another tensor. Returns scalar tensor."""
|
|
1676
1666
|
...
|
|
1677
1667
|
|
|
1678
|
-
def cumsum[Shape: IntTuple](
|
|
1668
|
+
def cumsum[Shape: IntTuple](
|
|
1669
|
+
self: Tensor[Shape], dim: builtins.int
|
|
1670
|
+
) -> Tensor[Shape]:
|
|
1679
1671
|
"""Cumulative sum along dimension. Shape-preserving operation."""
|
|
1680
1672
|
...
|
|
1681
1673
|
|
|
1682
|
-
def cumprod[Shape: IntTuple](
|
|
1674
|
+
def cumprod[Shape: IntTuple](
|
|
1675
|
+
self: Tensor[Shape], dim: builtins.int
|
|
1676
|
+
) -> Tensor[Shape]:
|
|
1683
1677
|
"""Cumulative product along dimension. Shape-preserving operation."""
|
|
1684
1678
|
...
|
|
1685
1679
|
|
|
1686
1680
|
def cummax[Shape: IntTuple](
|
|
1687
|
-
self: Tensor[Shape], dim: int
|
|
1681
|
+
self: Tensor[Shape], dim: builtins.int
|
|
1688
1682
|
) -> return_types.cummax[Shape]:
|
|
1689
1683
|
"""Cumulative maximum along dimension. Returns (values, indices). Shape-preserving operation."""
|
|
1690
1684
|
...
|
|
1691
1685
|
|
|
1692
1686
|
def cummin[Shape: IntTuple](
|
|
1693
|
-
self: Tensor[Shape], dim: int
|
|
1687
|
+
self: Tensor[Shape], dim: builtins.int
|
|
1694
1688
|
) -> return_types.cummin[Shape]:
|
|
1695
1689
|
"""Cumulative minimum along dimension. Returns (values, indices). Shape-preserving operation."""
|
|
1696
1690
|
...
|
|
@@ -1707,17 +1701,17 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
1707
1701
|
self: Tensor[Shape],
|
|
1708
1702
|
k: K,
|
|
1709
1703
|
dim: Dim = -1,
|
|
1710
|
-
largest: bool = True,
|
|
1711
|
-
sorted: bool = True,
|
|
1704
|
+
largest: builtins.bool = True,
|
|
1705
|
+
sorted: builtins.bool = True,
|
|
1712
1706
|
) -> return_types.topk[topk_shape(Shape, Dim, K)]:
|
|
1713
1707
|
"""Top k elements. Returns (values, indices). Shape inference via meta-shape: torch.Tensor.topk"""
|
|
1714
1708
|
...
|
|
1715
1709
|
|
|
1716
1710
|
def sort[Shape: IntTuple](
|
|
1717
1711
|
self: Tensor[Shape],
|
|
1718
|
-
dim: int = -1,
|
|
1719
|
-
descending: bool = False,
|
|
1720
|
-
stable: bool = False,
|
|
1712
|
+
dim: builtins.int = -1,
|
|
1713
|
+
descending: builtins.bool = False,
|
|
1714
|
+
stable: builtins.bool = False,
|
|
1721
1715
|
) -> return_types.sort[Shape]:
|
|
1722
1716
|
"""Sort tensor. Returns (values, indices). Shape-preserving operation."""
|
|
1723
1717
|
...
|
|
@@ -1727,7 +1721,10 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
1727
1721
|
Dim: Flag[builtins.int],
|
|
1728
1722
|
Keepdim: Flag[builtins.bool],
|
|
1729
1723
|
](
|
|
1730
|
-
self: Tensor[Shape],
|
|
1724
|
+
self: Tensor[Shape],
|
|
1725
|
+
k: builtins.int,
|
|
1726
|
+
dim: Dim = -1,
|
|
1727
|
+
keepdim: Keepdim = False,
|
|
1731
1728
|
) -> return_types.kthvalue[reduce_shape(Shape, Dim, Keepdim)]:
|
|
1732
1729
|
"""Kth smallest value. Returns (values, indices). Shape inference via meta-shape: torch.Tensor.kthvalue"""
|
|
1733
1730
|
...
|
|
@@ -1745,11 +1742,11 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
1745
1742
|
"""Create diagonal tensor. Shape inference via meta-shape: torch.Tensor.diag_embed"""
|
|
1746
1743
|
...
|
|
1747
1744
|
|
|
1748
|
-
def tril(self, diagonal: int = 0) -> Self:
|
|
1745
|
+
def tril(self, diagonal: builtins.int = 0) -> Self:
|
|
1749
1746
|
"""Lower triangular part. Shape inference via generic fixture signature."""
|
|
1750
1747
|
...
|
|
1751
1748
|
|
|
1752
|
-
def triu(self, diagonal: int = 0) -> Self:
|
|
1749
|
+
def triu(self, diagonal: builtins.int = 0) -> Self:
|
|
1753
1750
|
"""Upper triangular part. Shape inference via generic fixture signature."""
|
|
1754
1751
|
...
|
|
1755
1752
|
|
|
@@ -2089,7 +2086,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2089
2086
|
"""Digamma function. Shape inference via generic fixture signature."""
|
|
2090
2087
|
...
|
|
2091
2088
|
|
|
2092
|
-
def polygamma(self, n: int) -> Self:
|
|
2089
|
+
def polygamma(self, n: builtins.int) -> Self:
|
|
2093
2090
|
"""Polygamma function. Shape inference via generic fixture signature."""
|
|
2094
2091
|
...
|
|
2095
2092
|
|
|
@@ -2216,7 +2213,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2216
2213
|
|
|
2217
2214
|
# ==== Phase 4: Advanced Linear Algebra Methods ====
|
|
2218
2215
|
|
|
2219
|
-
def cholesky(self, upper: bool = False) -> Self:
|
|
2216
|
+
def cholesky(self, upper: builtins.bool = False) -> Self:
|
|
2220
2217
|
"""Cholesky decomposition. Shape inference via generic fixture signature."""
|
|
2221
2218
|
...
|
|
2222
2219
|
|
|
@@ -2244,7 +2241,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2244
2241
|
def slogdet[Shape: IntTuple](
|
|
2245
2242
|
self: Tensor[Shape],
|
|
2246
2243
|
) -> return_types.slogdet[slogdet_shape(Shape)]: ...
|
|
2247
|
-
def matrix_power(self, n: int) -> Self:
|
|
2244
|
+
def matrix_power(self, n: builtins.int) -> Self:
|
|
2248
2245
|
"""Matrix power. Shape inference via generic fixture signature."""
|
|
2249
2246
|
...
|
|
2250
2247
|
|
|
@@ -2336,7 +2333,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2336
2333
|
self,
|
|
2337
2334
|
indices: tuple[Tensor, ...],
|
|
2338
2335
|
values: Tensor,
|
|
2339
|
-
accumulate: bool = False,
|
|
2336
|
+
accumulate: builtins.bool = False,
|
|
2340
2337
|
) -> Self:
|
|
2341
2338
|
"""Put values at indices. Shape inference via generic fixture signature."""
|
|
2342
2339
|
...
|
|
@@ -2345,7 +2342,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2345
2342
|
self,
|
|
2346
2343
|
indices: tuple[Tensor, ...],
|
|
2347
2344
|
values: Tensor,
|
|
2348
|
-
accumulate: bool = False,
|
|
2345
|
+
accumulate: builtins.bool = False,
|
|
2349
2346
|
) -> Self:
|
|
2350
2347
|
"""Put values at indices in-place. Shape inference via generic fixture signature."""
|
|
2351
2348
|
...
|
|
@@ -2379,7 +2376,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2379
2376
|
self: Tensor[Shape],
|
|
2380
2377
|
index: Tensor[IndexShape],
|
|
2381
2378
|
source: Tensor[SourceShape],
|
|
2382
|
-
accumulate: bool = False,
|
|
2379
|
+
accumulate: builtins.bool = False,
|
|
2383
2380
|
) -> Tensor[put_shape(Shape, IndexShape, SourceShape)]:
|
|
2384
2381
|
"""Put values at indices. Shape inference via generic fixture signature."""
|
|
2385
2382
|
...
|
|
@@ -2388,7 +2385,7 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2388
2385
|
self: Tensor[Shape],
|
|
2389
2386
|
index: Tensor[IndexShape],
|
|
2390
2387
|
source: Tensor[SourceShape],
|
|
2391
|
-
accumulate: bool = False,
|
|
2388
|
+
accumulate: builtins.bool = False,
|
|
2392
2389
|
) -> Tensor[put_shape(Shape, IndexShape, SourceShape)]:
|
|
2393
2390
|
"""Put values at indices in-place. Shape inference via generic fixture signature."""
|
|
2394
2391
|
...
|
|
@@ -2438,8 +2435,8 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2438
2435
|
|
|
2439
2436
|
def random_(
|
|
2440
2437
|
self,
|
|
2441
|
-
low: int = 0,
|
|
2442
|
-
high: int | None = None,
|
|
2438
|
+
low: builtins.int = 0,
|
|
2439
|
+
high: builtins.int | None = None,
|
|
2443
2440
|
*,
|
|
2444
2441
|
generator: Generator | None = None,
|
|
2445
2442
|
) -> Self:
|
|
@@ -2468,6 +2465,8 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
|
|
|
2468
2465
|
"""Return the number of elements."""
|
|
2469
2466
|
...
|
|
2470
2467
|
|
|
2468
|
+
FloatTensor = Tensor
|
|
2469
|
+
|
|
2471
2470
|
# ============================================================================
|
|
2472
2471
|
# Module-level Functions
|
|
2473
2472
|
# ============================================================================
|
|
@@ -2478,6 +2477,78 @@ def matmul[Left: IntTuple, Right: IntTuple](
|
|
|
2478
2477
|
"""Matrix multiplication function. Shape inference via meta-shape: torch.matmul"""
|
|
2479
2478
|
...
|
|
2480
2479
|
|
|
2480
|
+
@overload
|
|
2481
|
+
def unique(
|
|
2482
|
+
input: Tensor,
|
|
2483
|
+
sorted: builtins.bool = True,
|
|
2484
|
+
return_inverse: Literal[False] = False,
|
|
2485
|
+
return_counts: Literal[False] = False,
|
|
2486
|
+
dim: None = None,
|
|
2487
|
+
) -> Tensor[[Any]]: ...
|
|
2488
|
+
@overload
|
|
2489
|
+
def unique(
|
|
2490
|
+
input: Tensor,
|
|
2491
|
+
sorted: builtins.bool = True,
|
|
2492
|
+
return_inverse: Literal[False] = False,
|
|
2493
|
+
return_counts: Literal[False] = False,
|
|
2494
|
+
dim: builtins.int = 0,
|
|
2495
|
+
) -> Tensor: ...
|
|
2496
|
+
@overload
|
|
2497
|
+
def unique[Shape: IntTuple](
|
|
2498
|
+
input: Tensor[Shape],
|
|
2499
|
+
sorted: builtins.bool = True,
|
|
2500
|
+
return_inverse: Literal[True] = True,
|
|
2501
|
+
return_counts: Literal[False] = False,
|
|
2502
|
+
dim: None = None,
|
|
2503
|
+
) -> tuple[Tensor[[Any]], Tensor[Shape]]: ...
|
|
2504
|
+
@overload
|
|
2505
|
+
def unique(
|
|
2506
|
+
input: Tensor,
|
|
2507
|
+
sorted: builtins.bool = True,
|
|
2508
|
+
return_inverse: Literal[True] = True,
|
|
2509
|
+
return_counts: Literal[False] = False,
|
|
2510
|
+
dim: builtins.int = 0,
|
|
2511
|
+
) -> tuple[Tensor, Tensor[[Any]]]: ...
|
|
2512
|
+
@overload
|
|
2513
|
+
def unique(
|
|
2514
|
+
input: Tensor,
|
|
2515
|
+
sorted: builtins.bool = True,
|
|
2516
|
+
return_inverse: Literal[False] = False,
|
|
2517
|
+
return_counts: Literal[True] = True,
|
|
2518
|
+
dim: None = None,
|
|
2519
|
+
) -> tuple[Tensor[[Any]], Tensor[[Any]]]: ...
|
|
2520
|
+
@overload
|
|
2521
|
+
def unique(
|
|
2522
|
+
input: Tensor,
|
|
2523
|
+
sorted: builtins.bool = True,
|
|
2524
|
+
return_inverse: Literal[False] = False,
|
|
2525
|
+
return_counts: Literal[True] = True,
|
|
2526
|
+
dim: builtins.int = 0,
|
|
2527
|
+
) -> tuple[Tensor, Tensor[[Any]]]: ...
|
|
2528
|
+
@overload
|
|
2529
|
+
def unique[Shape: IntTuple](
|
|
2530
|
+
input: Tensor[Shape],
|
|
2531
|
+
sorted: builtins.bool = True,
|
|
2532
|
+
return_inverse: Literal[True] = True,
|
|
2533
|
+
return_counts: Literal[True] = True,
|
|
2534
|
+
dim: None = None,
|
|
2535
|
+
) -> tuple[Tensor[[Any]], Tensor[Shape], Tensor[[Any]]]: ...
|
|
2536
|
+
@overload
|
|
2537
|
+
def unique(
|
|
2538
|
+
input: Tensor,
|
|
2539
|
+
sorted: builtins.bool = True,
|
|
2540
|
+
return_inverse: Literal[True] = True,
|
|
2541
|
+
return_counts: Literal[True] = True,
|
|
2542
|
+
dim: builtins.int = 0,
|
|
2543
|
+
) -> tuple[Tensor, Tensor[[Any]], Tensor[[Any]]]: ...
|
|
2544
|
+
@overload
|
|
2545
|
+
def unique(
|
|
2546
|
+
input: Tensor,
|
|
2547
|
+
sorted: builtins.bool = True,
|
|
2548
|
+
return_inverse: builtins.bool = False,
|
|
2549
|
+
return_counts: builtins.bool = False,
|
|
2550
|
+
dim: builtins.int | None = None,
|
|
2551
|
+
) -> Tensor | tuple[Tensor, Tensor] | tuple[Tensor, Tensor, Tensor]: ...
|
|
2481
2552
|
def cat[Shapes: IntTuples, Dim: Flag[builtins.int]](
|
|
2482
2553
|
tensors: MapIntTuples[lambda S: Tensor[S], Shapes], dim: Dim = 0
|
|
2483
2554
|
) -> Tensor[cat_shape(Shapes, Dim)]:
|
|
@@ -4107,7 +4178,7 @@ def poisson[Shape: IntTuple](input: Tensor[Shape]) -> Tensor[Shape]:
|
|
|
4107
4178
|
...
|
|
4108
4179
|
|
|
4109
4180
|
# Tensor property functions
|
|
4110
|
-
def is_tensor(obj: object, /) ->
|
|
4181
|
+
def is_tensor(obj: object, /) -> TypeIs[Tensor]:
|
|
4111
4182
|
"""Return whether an object is a PyTorch tensor."""
|
|
4112
4183
|
...
|
|
4113
4184
|
|
|
@@ -4185,6 +4256,17 @@ def from_numpy(ndarray: Any) -> Tensor:
|
|
|
4185
4256
|
"""Create a CPU tensor that shares memory with a numpy array."""
|
|
4186
4257
|
...
|
|
4187
4258
|
|
|
4259
|
+
@overload
|
|
4260
|
+
def randint[Shape: IntTuple](
|
|
4261
|
+
high: int,
|
|
4262
|
+
size: Shape,
|
|
4263
|
+
*,
|
|
4264
|
+
generator: Any = None,
|
|
4265
|
+
dtype: Any = None,
|
|
4266
|
+
device: Any = None,
|
|
4267
|
+
requires_grad: bool = False,
|
|
4268
|
+
) -> Tensor[Shape]: ...
|
|
4269
|
+
@overload
|
|
4188
4270
|
def randint[Shape: IntTuple](
|
|
4189
4271
|
low: int,
|
|
4190
4272
|
high: int,
|