pyrefly-einops-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.
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/PKG-INFO +8 -7
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/README.md +5 -4
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/einops-stubs/__init__.pyi +13 -20
- pyrefly_einops_stubs-1.4.0.dev3/einops-stubs/_shapes.pyi +23 -0
- pyrefly_einops_stubs-1.4.0.dev3/einops-stubs/layers/__init__.pyi +0 -0
- pyrefly_einops_stubs-1.4.0.dev3/einops-stubs/layers/torch.pyi +39 -0
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/pyproject.toml +3 -3
- pyrefly_einops_stubs-1.4.0.dev2/einops-stubs/_shapes.pyi +0 -23
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/LICENSE +0 -0
- {pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/einops-stubs/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: pyrefly-einops-stubs
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev3
|
|
4
4
|
Summary: Einops 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,15 +33,16 @@ Classifier: Programming Language :: Python
|
|
|
33
33
|
Classifier: Programming Language :: Python :: 3
|
|
34
34
|
Classifier: Typing :: Stubs Only
|
|
35
35
|
Requires-Python: >=3.12
|
|
36
|
-
Requires-Dist: pyrefly-shape-extensions==1.4.0.
|
|
37
|
-
Requires-Dist: pyrefly-torch-stubs==1.4.0.
|
|
36
|
+
Requires-Dist: pyrefly-shape-extensions==1.4.0.dev3
|
|
37
|
+
Requires-Dist: pyrefly-torch-stubs==1.4.0.dev3
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
|
|
40
40
|
# Pyrefly einops shape stubs
|
|
41
41
|
|
|
42
42
|
This package is a PEP 561 stub-only distribution for `einops`. It provides
|
|
43
43
|
shape-aware annotations for `rearrange`, `reduce`, `repeat`, and `einsum` using
|
|
44
|
-
Pyrefly's type-level shape DSL.
|
|
44
|
+
Pyrefly's type-level shape DSL. The `einops.layers.torch` `Rearrange` and `Reduce`
|
|
45
|
+
modules preserve the constructor pattern and axis lengths across calls.
|
|
45
46
|
|
|
46
47
|
The precise annotations currently target PyTorch. The runtime corpus also
|
|
47
48
|
exercises NumPy and JAX to validate that the shared einops pattern semantics
|
|
@@ -50,9 +51,9 @@ agree across backends.
|
|
|
50
51
|
TODO: Once Pyrefly supports a `MapShape` type operator, make the annotations
|
|
51
52
|
generic over array libraries while preserving the input's nominal array type.
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
Literal `axes_lengths` keyword arguments are carried into the shape rules, so named
|
|
55
|
+
input splits and repeated output axes remain tracked. Dynamically unpacked mappings
|
|
56
|
+
preserve the known rank but use gradual dimensions for unknown axis lengths.
|
|
56
57
|
|
|
57
58
|
Run the static tests with:
|
|
58
59
|
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
This package is a PEP 561 stub-only distribution for `einops`. It provides
|
|
4
4
|
shape-aware annotations for `rearrange`, `reduce`, `repeat`, and `einsum` using
|
|
5
|
-
Pyrefly's type-level shape DSL.
|
|
5
|
+
Pyrefly's type-level shape DSL. The `einops.layers.torch` `Rearrange` and `Reduce`
|
|
6
|
+
modules preserve the constructor pattern and axis lengths across calls.
|
|
6
7
|
|
|
7
8
|
The precise annotations currently target PyTorch. The runtime corpus also
|
|
8
9
|
exercises NumPy and JAX to validate that the shared einops pattern semantics
|
|
@@ -11,9 +12,9 @@ agree across backends.
|
|
|
11
12
|
TODO: Once Pyrefly supports a `MapShape` type operator, make the annotations
|
|
12
13
|
generic over array libraries while preserving the input's nominal array type.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
Literal `axes_lengths` keyword arguments are carried into the shape rules, so named
|
|
16
|
+
input splits and repeated output axes remain tracked. Dynamically unpacked mappings
|
|
17
|
+
preserve the known rank but use gradual dimensions for unknown axis lengths.
|
|
17
18
|
|
|
18
19
|
Run the static tests with:
|
|
19
20
|
|
{pyrefly_einops_stubs-1.4.0.dev2 → pyrefly_einops_stubs-1.4.0.dev3}/einops-stubs/__init__.pyi
RENAMED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
from collections.abc import Sequence
|
|
7
7
|
from typing import Any, overload, Protocol
|
|
8
8
|
|
|
9
|
-
from shape_extensions import Flag, IntTuple
|
|
9
|
+
from shape_extensions import CaptureNamedInts, Flag, IntTuple, NamedInts
|
|
10
10
|
from torch import Tensor
|
|
11
11
|
|
|
12
12
|
from ._shapes import einsum_shape, rearrange_shape, reduce_shape, repeat_shape
|
|
@@ -35,31 +35,24 @@ def unpack(
|
|
|
35
35
|
# TODO: Replace these Torch-specific overloads with library-agnostic `MapShape`
|
|
36
36
|
# signatures that preserve each input array's nominal type.
|
|
37
37
|
@overload
|
|
38
|
-
def rearrange[Shape: IntTuple, Pattern: Flag[str]](
|
|
39
|
-
tensor: Tensor[Shape], pattern: Pattern
|
|
40
|
-
) -> Tensor[rearrange_shape(Pattern, Shape)]: ...
|
|
41
|
-
@overload
|
|
42
|
-
def rearrange(
|
|
43
|
-
tensor: Tensor, pattern: str, **axes_lengths: int
|
|
44
|
-
) -> Tensor[IntTuple]: ...
|
|
38
|
+
def rearrange[Shape: IntTuple, Pattern: Flag[str], Axes: NamedInts](
|
|
39
|
+
tensor: Tensor[Shape], pattern: Pattern, **axes_lengths: CaptureNamedInts[Axes]
|
|
40
|
+
) -> Tensor[rearrange_shape(Pattern, Shape, Axes)]: ...
|
|
45
41
|
@overload
|
|
46
42
|
def rearrange(tensor: Any, pattern: str, **axes_lengths: int) -> Any: ...
|
|
47
43
|
@overload
|
|
48
|
-
def reduce[Shape: IntTuple, Pattern: Flag[str]](
|
|
49
|
-
tensor: Tensor[Shape],
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
) -> Tensor[IntTuple]: ...
|
|
44
|
+
def reduce[Shape: IntTuple, Pattern: Flag[str], Axes: NamedInts](
|
|
45
|
+
tensor: Tensor[Shape],
|
|
46
|
+
pattern: Pattern,
|
|
47
|
+
reduction: Any,
|
|
48
|
+
**axes_lengths: CaptureNamedInts[Axes],
|
|
49
|
+
) -> Tensor[reduce_shape(Pattern, Shape, Axes)]: ...
|
|
55
50
|
@overload
|
|
56
51
|
def reduce(tensor: Any, pattern: str, reduction: Any, **axes_lengths: int) -> Any: ...
|
|
57
52
|
@overload
|
|
58
|
-
def repeat[Shape: IntTuple, Pattern: Flag[str]](
|
|
59
|
-
tensor: Tensor[Shape], pattern: Pattern
|
|
60
|
-
) -> Tensor[repeat_shape(Pattern, Shape)]: ...
|
|
61
|
-
@overload
|
|
62
|
-
def repeat(tensor: Tensor, pattern: str, **axes_lengths: int) -> Tensor[IntTuple]: ...
|
|
53
|
+
def repeat[Shape: IntTuple, Pattern: Flag[str], Axes: NamedInts](
|
|
54
|
+
tensor: Tensor[Shape], pattern: Pattern, **axes_lengths: CaptureNamedInts[Axes]
|
|
55
|
+
) -> Tensor[repeat_shape(Pattern, Shape, Axes)]: ...
|
|
63
56
|
@overload
|
|
64
57
|
def repeat(tensor: Any, pattern: str, **axes_lengths: int) -> Any: ...
|
|
65
58
|
@overload
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
import shape_extensions.dsl as dsl
|
|
7
|
+
from shape_extensions import IntTuple, IntTuples, NamedInts, type_shape_dsl_function
|
|
8
|
+
|
|
9
|
+
@type_shape_dsl_function
|
|
10
|
+
def rearrange_shape(pattern: str, shape: IntTuple, axes: NamedInts) -> IntTuple:
|
|
11
|
+
return dsl.rearrange(pattern, shape, axes)
|
|
12
|
+
|
|
13
|
+
@type_shape_dsl_function
|
|
14
|
+
def reduce_shape(pattern: str, shape: IntTuple, axes: NamedInts) -> IntTuple:
|
|
15
|
+
return dsl.reduce(pattern, shape, axes)
|
|
16
|
+
|
|
17
|
+
@type_shape_dsl_function
|
|
18
|
+
def repeat_shape(pattern: str, shape: IntTuple, axes: NamedInts) -> IntTuple:
|
|
19
|
+
return dsl.repeat(pattern, shape, axes)
|
|
20
|
+
|
|
21
|
+
@type_shape_dsl_function
|
|
22
|
+
def einsum_shape(pattern: str, shapes: IntTuples) -> IntTuple:
|
|
23
|
+
return dsl.einops_einsum(pattern, shapes)
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
from shape_extensions import CaptureNamedInts, Flag, IntTuple, NamedInts
|
|
7
|
+
from torch import Tensor
|
|
8
|
+
from torch.nn import Module
|
|
9
|
+
|
|
10
|
+
from .._shapes import rearrange_shape, reduce_shape
|
|
11
|
+
|
|
12
|
+
class Rearrange[Pattern: Flag[str], Axes: NamedInts](Module):
|
|
13
|
+
def __init__(
|
|
14
|
+
self, pattern: Pattern, **axes_lengths: CaptureNamedInts[Axes]
|
|
15
|
+
) -> None: ...
|
|
16
|
+
def forward[Shape: IntTuple](
|
|
17
|
+
self, input: Tensor[Shape]
|
|
18
|
+
) -> Tensor[rearrange_shape(Pattern, Shape, Axes)]: ...
|
|
19
|
+
|
|
20
|
+
class Reduce[Pattern: Flag[str], Axes: NamedInts](Module):
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
pattern: Pattern,
|
|
24
|
+
reduction: str,
|
|
25
|
+
**axes_lengths: CaptureNamedInts[Axes],
|
|
26
|
+
) -> None: ...
|
|
27
|
+
def forward[Shape: IntTuple](
|
|
28
|
+
self, input: Tensor[Shape]
|
|
29
|
+
) -> Tensor[reduce_shape(Pattern, Shape, Axes)]: ...
|
|
30
|
+
|
|
31
|
+
class EinMix(Module):
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
pattern: str,
|
|
35
|
+
weight_shape: str,
|
|
36
|
+
bias_shape: str | None = None,
|
|
37
|
+
**axes_lengths: int,
|
|
38
|
+
) -> None: ...
|
|
39
|
+
def forward(self, input: Tensor[IntTuple]) -> Tensor[IntTuple]: ...
|
|
@@ -8,7 +8,7 @@ description = "Einops type stubs with tensor-shape tracking, maintained by Pyref
|
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
requires-python = ">=3.12"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
11
|
-
version = "1.4.0.
|
|
11
|
+
version = "1.4.0.dev3"
|
|
12
12
|
keywords = ["typechecker", "typechecking", "stubs", "einops"]
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Development Status :: 4 - Beta",
|
|
@@ -18,8 +18,8 @@ classifiers = [
|
|
|
18
18
|
"Typing :: Stubs Only",
|
|
19
19
|
]
|
|
20
20
|
dependencies = [
|
|
21
|
-
"pyrefly-shape-extensions==1.4.0.
|
|
22
|
-
"pyrefly-torch-stubs==1.4.0.
|
|
21
|
+
"pyrefly-shape-extensions==1.4.0.dev3",
|
|
22
|
+
"pyrefly-torch-stubs==1.4.0.dev3",
|
|
23
23
|
]
|
|
24
24
|
|
|
25
25
|
[project.urls]
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
#
|
|
3
|
-
# This source code is licensed under the MIT license found in the
|
|
4
|
-
# LICENSE file in the root directory of this source tree.
|
|
5
|
-
|
|
6
|
-
import shape_extensions.dsl as dsl
|
|
7
|
-
from shape_extensions import IntTuple, IntTuples, type_shape_dsl_function
|
|
8
|
-
|
|
9
|
-
@type_shape_dsl_function
|
|
10
|
-
def rearrange_shape(pattern: str, shape: IntTuple) -> IntTuple:
|
|
11
|
-
return dsl.rearrange(pattern, shape)
|
|
12
|
-
|
|
13
|
-
@type_shape_dsl_function
|
|
14
|
-
def reduce_shape(pattern: str, shape: IntTuple) -> IntTuple:
|
|
15
|
-
return dsl.reduce(pattern, shape)
|
|
16
|
-
|
|
17
|
-
@type_shape_dsl_function
|
|
18
|
-
def repeat_shape(pattern: str, shape: IntTuple) -> IntTuple:
|
|
19
|
-
return dsl.repeat(pattern, shape)
|
|
20
|
-
|
|
21
|
-
@type_shape_dsl_function
|
|
22
|
-
def einsum_shape(pattern: str, shapes: IntTuples) -> IntTuple:
|
|
23
|
-
return dsl.einops_einsum(pattern, shapes)
|
|
File without changes
|
|
File without changes
|