pyrefly-torch-stubs 1.4.0.dev2__tar.gz → 1.4.0.dev3__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.
Files changed (26) hide show
  1. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/PKG-INFO +2 -2
  2. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/pyproject.toml +2 -2
  3. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/__init__.pyi +16 -17
  4. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/__init__.pyi +3 -3
  5. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/linalg.pyi +12 -12
  6. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/__init__.pyi +4 -6
  7. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/functional.pyi +3 -4
  8. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/LICENSE +0 -0
  9. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/README.md +0 -0
  10. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/test/README.md +0 -0
  11. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/_shapes.pyi +0 -0
  12. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/_tensor.pyi +0 -0
  13. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/beta.pyi +0 -0
  14. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/categorical.pyi +0 -0
  15. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/constraints.pyi +0 -0
  16. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/transformed_distribution.pyi +0 -0
  17. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/distributions/transforms.pyi +0 -0
  18. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/fft.pyi +0 -0
  19. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/attention/__init__.pyi +0 -0
  20. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/attention/flex_attention.pyi +0 -0
  21. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/init.pyi +0 -0
  22. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/modules/__init__.pyi +0 -0
  23. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/modules/module.pyi +0 -0
  24. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/nn/parameter.pyi +0 -0
  25. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/py.typed +0 -0
  26. {pyrefly_torch_stubs-1.4.0.dev2 → pyrefly_torch_stubs-1.4.0.dev3}/torch-stubs/return_types.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyrefly-torch-stubs
3
- Version: 1.4.0.dev2
3
+ Version: 1.4.0.dev3
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,7 @@ 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.dev2
36
+ Requires-Dist: pyrefly-shape-extensions==1.4.0.dev3
37
37
  Description-Content-Type: text/markdown
38
38
 
39
39
  # pyrefly-torch-stubs
@@ -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.dev2"
11
+ version = "1.4.0.dev3"
12
12
  keywords = ["typechecker", "typechecking", "stubs", "torch", "pytorch"]
13
13
  classifiers = [
14
14
  "Development Status :: 4 - Beta",
@@ -18,7 +18,7 @@ classifiers = [
18
18
  "Typing :: Stubs Only",
19
19
  ]
20
20
  dependencies = [
21
- "pyrefly-shape-extensions==1.4.0.dev2",
21
+ "pyrefly-shape-extensions==1.4.0.dev3",
22
22
  ]
23
23
 
24
24
  [project.urls]
@@ -18,7 +18,6 @@ from typing import Any, Callable, Literal, overload, Self, TYPE_CHECKING, Unpack
18
18
 
19
19
  from shape_extensions import (
20
20
  broadcast,
21
- Elements,
22
21
  Flag,
23
22
  Index,
24
23
  index_shape,
@@ -2226,20 +2225,20 @@ class Tensor[Shape: _Shape = _Shape](_TensorBase):
2226
2225
  ...
2227
2226
 
2228
2227
  def det[Batch: IntTuple, M: IntVar, N: IntVar](
2229
- self: Tensor[[*Elements[Batch], M, N]],
2228
+ self: Tensor[[*Batch, M, N]],
2230
2229
  ) -> Tensor[Batch]:
2231
2230
  """Determinant. Returns batch dimensions only (drops last 2 dims)."""
2232
2231
  ...
2233
2232
 
2234
2233
  def logdet[Batch: IntTuple, M: IntVar, N: IntVar](
2235
- self: Tensor[[*Elements[Batch], M, N]],
2234
+ self: Tensor[[*Batch, M, N]],
2236
2235
  ) -> Tensor[Batch]:
2237
2236
  """Log determinant. Returns batch dimensions only (drops last 2 dims)."""
2238
2237
  ...
2239
2238
 
2240
2239
  @overload
2241
2240
  def slogdet[Batch: IntTuple, M: IntVar, N: IntVar](
2242
- self: Tensor[[*Elements[Batch], M, N]],
2241
+ self: Tensor[[*Batch, M, N]],
2243
2242
  ) -> return_types.slogdet[Batch]: ...
2244
2243
  @overload
2245
2244
  def slogdet[Shape: IntTuple](
@@ -3831,16 +3830,16 @@ def einsum[Spec: Flag[str], Shapes: IntTuples](
3831
3830
  # Eigenvalue decomposition
3832
3831
  @overload
3833
3832
  def eig[Batch: IntTuple, M: IntVar, N: IntVar](
3834
- self: Tensor[[*Elements[Batch], M, N]], eigenvectors: bool = False
3835
- ) -> tuple[Tensor[[*Elements[Batch], M]], Tensor[[*Elements[Batch], M, N]]]: ...
3833
+ self: Tensor[[*Batch, M, N]], eigenvectors: bool = False
3834
+ ) -> tuple[Tensor[[*Batch, M]], Tensor[[*Batch, M, N]]]: ...
3836
3835
  @overload
3837
3836
  def eig[Shape: IntTuple](
3838
3837
  self: Tensor[Shape], eigenvectors: bool = False
3839
3838
  ) -> tuple[Tensor[eig_shape(Shape)], Tensor[Shape]]: ...
3840
3839
  @overload
3841
3840
  def eigh[Batch: IntTuple, M: IntVar, N: IntVar](
3842
- self: Tensor[[*Elements[Batch], M, N]], UPLO: str = "L"
3843
- ) -> tuple[Tensor[[*Elements[Batch], M]], Tensor[[*Elements[Batch], M, N]]]: ...
3841
+ self: Tensor[[*Batch, M, N]], UPLO: str = "L"
3842
+ ) -> tuple[Tensor[[*Batch, M]], Tensor[[*Batch, M, N]]]: ...
3844
3843
  @overload
3845
3844
  def eigh[Shape: IntTuple](
3846
3845
  self: Tensor[Shape], UPLO: str = "L"
@@ -3876,20 +3875,20 @@ def inverse[Shape: IntTuple](input: Tensor[Shape]) -> Tensor[Shape]:
3876
3875
 
3877
3876
  # Determinant
3878
3877
  def det[Batch: IntTuple, M: IntVar, N: IntVar](
3879
- input: Tensor[[*Elements[Batch], M, N]],
3878
+ input: Tensor[[*Batch, M, N]],
3880
3879
  ) -> Tensor[Batch]:
3881
3880
  """Determinant. Returns batch dimensions only (drops last 2 dims)."""
3882
3881
  ...
3883
3882
 
3884
3883
  def logdet[Batch: IntTuple, M: IntVar, N: IntVar](
3885
- input: Tensor[[*Elements[Batch], M, N]],
3884
+ input: Tensor[[*Batch, M, N]],
3886
3885
  ) -> Tensor[Batch]:
3887
3886
  """Log determinant. Returns batch dimensions only (drops last 2 dims)."""
3888
3887
  ...
3889
3888
 
3890
3889
  @overload
3891
3890
  def slogdet[Batch: IntTuple, M: IntVar, N: IntVar](
3892
- self: Tensor[[*Elements[Batch], M, N]],
3891
+ self: Tensor[[*Batch, M, N]],
3893
3892
  ) -> return_types.slogdet[Batch]: ...
3894
3893
  @overload
3895
3894
  def slogdet[Shape: IntTuple](
@@ -3912,7 +3911,7 @@ def trace[M: IntVar, N: IntVar](input: Tensor[[M, N]]) -> Tensor[[]]:
3912
3911
 
3913
3912
  # Matrix rank
3914
3913
  def matrix_rank[Batch: IntTuple, M: IntVar, N: IntVar](
3915
- input: Tensor[[*Elements[Batch], M, N]],
3914
+ input: Tensor[[*Batch, M, N]],
3916
3915
  tol: builtins.float | None = None,
3917
3916
  symmetric: bool = False,
3918
3917
  ) -> Tensor[Batch]:
@@ -4233,11 +4232,11 @@ def polar[Shape: IntTuple](abs: Tensor[Shape], angle: Tensor[Shape]) -> Tensor[S
4233
4232
  """Construct complex tensor from polar coordinates. Shape-preserving operation."""
4234
4233
  ...
4235
4234
 
4236
- def view_as_complex[S: IntTuple](input: Tensor[[*Elements[S], 2]]) -> Tensor[S]:
4235
+ def view_as_complex[S: IntTuple](input: Tensor[[*S, 2]]) -> Tensor[S]:
4237
4236
  """View a real tensor as complex. Last dim of size 2 is consumed."""
4238
4237
  ...
4239
4238
 
4240
- def view_as_real[S: IntTuple](input: Tensor[S]) -> Tensor[[*Elements[S], 2]]:
4239
+ def view_as_real[S: IntTuple](input: Tensor[S]) -> Tensor[[*S, 2]]:
4241
4240
  """View a complex tensor as real. Appends trailing dim of size 2."""
4242
4241
  ...
4243
4242
 
@@ -4284,10 +4283,10 @@ def addmm[N: IntVar, K: IntVar, M: IntVar](
4284
4283
  ...
4285
4284
 
4286
4285
  def cross[B: IntTuple](
4287
- input: Tensor[[*Elements[B], 3]],
4288
- other: Tensor[[*Elements[B], 3]],
4286
+ input: Tensor[[*B, 3]],
4287
+ other: Tensor[[*B, 3]],
4289
4288
  dim: int = -1,
4290
- ) -> Tensor[[*Elements[B], 3]]:
4289
+ ) -> Tensor[[*B, 3]]:
4291
4290
  """Cross product of two tensors along a dimension of size 3."""
4292
4291
  ...
4293
4292
 
@@ -15,7 +15,7 @@ Submodules re-exported to support original import patterns:
15
15
 
16
16
  from typing import Any
17
17
 
18
- from shape_extensions import broadcast, Elements, IntTuple, IntVar
18
+ from shape_extensions import broadcast, IntTuple, IntVar
19
19
  from torch import Tensor
20
20
  from torch._shapes import distribution_sample_shape
21
21
 
@@ -116,8 +116,8 @@ class Categorical[BatchShape: IntTuple, Categories: IntVar](Distribution[BatchSh
116
116
  """Categorical distribution."""
117
117
  def __init__(
118
118
  self,
119
- probs: Tensor[[*Elements[BatchShape], Categories]] | None = None,
120
- logits: Tensor[[*Elements[BatchShape], Categories]] | None = None,
119
+ probs: Tensor[[*BatchShape, Categories]] | None = None,
120
+ logits: Tensor[[*BatchShape, Categories]] | None = None,
121
121
  validate_args: bool | None = None,
122
122
  ) -> None: ...
123
123
  def sample[SampleShape: IntTuple = []](
@@ -6,7 +6,7 @@
6
6
  # Type stubs for torch.linalg module (Phase 4: Advanced Linear Algebra)
7
7
  from typing import Any, overload
8
8
 
9
- from shape_extensions import Elements, Flag, IntTuple, IntVar
9
+ from shape_extensions import Flag, IntTuple, IntVar
10
10
  from torch import return_types, Tensor
11
11
  from torch._C import _LinAlgError as LinAlgError
12
12
  from torch._shapes import eig_shape, eigvals_shape, reduce_shape, slogdet_shape
@@ -14,16 +14,16 @@ from torch._shapes import eig_shape, eigvals_shape, reduce_shape, slogdet_shape
14
14
  # Eigenvalue decomposition
15
15
  @overload
16
16
  def eig[Batch: IntTuple, M: IntVar, N: IntVar](
17
- self: Tensor[[*Elements[Batch], M, N]],
18
- ) -> tuple[Tensor[[*Elements[Batch], M]], Tensor[[*Elements[Batch], M, N]]]: ...
17
+ self: Tensor[[*Batch, M, N]],
18
+ ) -> tuple[Tensor[[*Batch, M]], Tensor[[*Batch, M, N]]]: ...
19
19
  @overload
20
20
  def eig[Shape: IntTuple](
21
21
  self: Tensor[Shape],
22
22
  ) -> tuple[Tensor[eig_shape(Shape)], Tensor[Shape]]: ...
23
23
  @overload
24
24
  def eigh[Batch: IntTuple, M: IntVar, N: IntVar](
25
- self: Tensor[[*Elements[Batch], M, N]], UPLO: str = "L"
26
- ) -> tuple[Tensor[[*Elements[Batch], M]], Tensor[[*Elements[Batch], M, N]]]: ...
25
+ self: Tensor[[*Batch, M, N]], UPLO: str = "L"
26
+ ) -> tuple[Tensor[[*Batch, M]], Tensor[[*Batch, M, N]]]: ...
27
27
  @overload
28
28
  def eigh[Shape: IntTuple](
29
29
  self: Tensor[Shape], UPLO: str = "L"
@@ -32,14 +32,14 @@ def eigh[Shape: IntTuple](
32
32
  # Tier 3: Eigenvalues only (no eigenvectors)
33
33
  @overload
34
34
  def eigvals[Batch: IntTuple, M: IntVar, N: IntVar](
35
- self: Tensor[[*Elements[Batch], M, N]],
36
- ) -> Tensor[[*Elements[Batch], M]]: ...
35
+ self: Tensor[[*Batch, M, N]],
36
+ ) -> Tensor[[*Batch, M]]: ...
37
37
  @overload
38
38
  def eigvals[Shape: IntTuple](self: Tensor[Shape]) -> Tensor[eigvals_shape(Shape)]: ...
39
39
  @overload
40
40
  def eigvalsh[Batch: IntTuple, M: IntVar, N: IntVar](
41
- self: Tensor[[*Elements[Batch], M, N]], UPLO: str = "L"
42
- ) -> Tensor[[*Elements[Batch], M]]: ...
41
+ self: Tensor[[*Batch, M, N]], UPLO: str = "L"
42
+ ) -> Tensor[[*Batch, M]]: ...
43
43
  @overload
44
44
  def eigvalsh[Shape: IntTuple](
45
45
  self: Tensor[Shape], UPLO: str = "L"
@@ -66,13 +66,13 @@ def inv[Shape: IntTuple](input: Tensor[Shape]) -> Tensor[Shape]: ...
66
66
 
67
67
  # Determinant
68
68
  def det[Batch: IntTuple, M: IntVar, N: IntVar](
69
- input: Tensor[[*Elements[Batch], M, N]],
69
+ input: Tensor[[*Batch, M, N]],
70
70
  ) -> Tensor[Batch]: ...
71
71
 
72
72
  # Sign and log determinant
73
73
  @overload
74
74
  def slogdet[Batch: IntTuple, M: IntVar, N: IntVar](
75
- self: Tensor[[*Elements[Batch], M, N]],
75
+ self: Tensor[[*Batch, M, N]],
76
76
  ) -> return_types.linalg_slogdet[Batch]: ...
77
77
  @overload
78
78
  def slogdet[Shape: IntTuple](
@@ -87,7 +87,7 @@ def matrix_exp[Shape: IntTuple](input: Tensor[Shape]) -> Tensor[Shape]: ...
87
87
 
88
88
  # Matrix rank
89
89
  def matrix_rank[Batch: IntTuple, M: IntVar, N: IntVar](
90
- input: Tensor[[*Elements[Batch], M, N]], tol: float = None, hermitian: bool = False
90
+ input: Tensor[[*Batch, M, N]], tol: float = None, hermitian: bool = False
91
91
  ) -> Tensor[Batch]: ...
92
92
 
93
93
  # TODO: Add precise types and signatures for the remaining public API.
@@ -20,7 +20,7 @@ from typing import (
20
20
  TypeVar,
21
21
  )
22
22
 
23
- from shape_extensions import broadcast, Elements, Flag, IntTuple, IntVar
23
+ from shape_extensions import broadcast, Flag, IntTuple, IntVar
24
24
 
25
25
  if TYPE_CHECKING:
26
26
  from shape_extensions import Int as _Int, ProxyMethod
@@ -236,9 +236,7 @@ class Linear[IN: IntVar, OUT: IntVar](Module):
236
236
  device: Any = None,
237
237
  dtype: Any = None,
238
238
  ) -> None: ...
239
- def forward[Bs: IntTuple](
240
- self, input: Tensor[[*Elements[Bs], IN]]
241
- ) -> Tensor[[*Elements[Bs], OUT]]: ...
239
+ def forward[Bs: IntTuple](self, input: Tensor[[*Bs, IN]]) -> Tensor[[*Bs, OUT]]: ...
242
240
 
243
241
  # Dropout
244
242
  class Dropout(Module):
@@ -1386,8 +1384,8 @@ class LazyLinear[OUT: IntVar](Module):
1386
1384
  dtype: Any = None,
1387
1385
  ) -> None: ...
1388
1386
  def forward[Bs: IntTuple](
1389
- self, input: Tensor[[*Elements[Bs], Any]]
1390
- ) -> Tensor[[*Elements[Bs], OUT]]: ...
1387
+ self, input: Tensor[[*Bs, Any]]
1388
+ ) -> Tensor[[*Bs, OUT]]: ...
1391
1389
 
1392
1390
  class Flatten[StartDim: Flag[int], EndDim: Flag[int]](Module):
1393
1391
  """Flattens a contiguous range of dims.
@@ -25,7 +25,6 @@ import numpy as np
25
25
  import shape_extensions
26
26
  import torch as torch
27
27
  from shape_extensions import (
28
- Elements,
29
28
  Flag,
30
29
  gufunc_broadcast,
31
30
  Int as _Int,
@@ -1413,10 +1412,10 @@ def softmin[Shape: IntTuple](
1413
1412
  # ==============================================================================
1414
1413
 
1415
1414
  def linear[Bs: IntTuple, IN: IntVar, OUT: IntVar](
1416
- input: Tensor[[*Elements[Bs], IN]],
1415
+ input: Tensor[[*Bs, IN]],
1417
1416
  weight: Tensor[[OUT, IN]],
1418
1417
  bias: Tensor[[OUT]] | None = None,
1419
- ) -> Tensor[[*Elements[Bs], OUT]]:
1418
+ ) -> Tensor[[*Bs, OUT]]:
1420
1419
  """Linear transformation: y = xA^T + b. Shape inference via generic fixture signature."""
1421
1420
  ...
1422
1421
 
@@ -1508,7 +1507,7 @@ def cosine_similarity[S1: IntTuple, S2: IntTuple, Dim: Flag[builtins.int]](
1508
1507
  ...
1509
1508
 
1510
1509
  def grid_sample[B: IntVar, C: IntVar, Hout: IntVar, Wout: IntVar](
1511
- input: Tensor[[B, C, *Elements[IntTuple]]],
1510
+ input: Tensor[[B, C, *IntTuple]],
1512
1511
  grid: Tensor[[B, Hout, Wout, 2]],
1513
1512
  mode: str = "bilinear",
1514
1513
  padding_mode: str = "zeros",