lesiondiffusion-mlx 0.2.1__py3-none-any.whl

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.

Potentially problematic release.


This version of lesiondiffusion-mlx might be problematic. Click here for more details.

@@ -0,0 +1,110 @@
1
+ """Native array and dependency contracts used by the source implementation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Protocol
6
+
7
+ from tokenizers import Encoding
8
+
9
+ from lesiondiffusion_mlx._arrays import HostArray as HostArray
10
+
11
+ if TYPE_CHECKING:
12
+ from collections.abc import Callable, Sequence
13
+
14
+ import mlx.core as mx
15
+ from medmlx_core.typing import FastRuntime as CoreFastRuntime
16
+ from medmlx_core.typing import MlxRuntime
17
+
18
+ type Array = mx.array
19
+ type Dtype = mx.Dtype
20
+ type ArrayValue = bool | int | float | complex | list[ArrayValue] | tuple[ArrayValue, ...]
21
+
22
+ class ArrayConstructor(Protocol):
23
+ def __call__(
24
+ self,
25
+ value: HostArray | Array | ArrayValue,
26
+ /,
27
+ dtype: Dtype | None = None,
28
+ ) -> Array: ...
29
+
30
+ class TokenizerContract(Protocol):
31
+ def enable_truncation(self, max_length: int) -> None: ...
32
+ def enable_padding(self, *, length: int, pad_id: int, pad_token: str) -> None: ...
33
+ def encode_batch(self, inputs: Sequence[str]) -> list[Encoding]: ...
34
+
35
+ class MetalKernel(Protocol):
36
+ def __call__(
37
+ self,
38
+ *,
39
+ inputs: Sequence[Array],
40
+ template: Sequence[tuple[str, int | bool]],
41
+ grid: tuple[int, int, int],
42
+ threadgroup: tuple[int, int, int],
43
+ output_shapes: Sequence[Sequence[int]],
44
+ output_dtypes: Sequence[Dtype],
45
+ ) -> list[Array]: ...
46
+
47
+ class Fast(CoreFastRuntime, Protocol):
48
+ def scaled_dot_product_attention(self, *args: object, **kwargs: object) -> Array: ...
49
+
50
+ def metal_kernel(
51
+ self,
52
+ name: str,
53
+ input_names: Sequence[str],
54
+ output_names: Sequence[str],
55
+ source: str,
56
+ header: str = "",
57
+ ensure_row_contiguous: bool = True,
58
+ atomic_outputs: bool = False,
59
+ compile_options: object | None = None,
60
+ ) -> MetalKernel: ...
61
+
62
+ class Random(Protocol):
63
+ def seed(self, seed: int) -> None: ...
64
+ def normal(self, shape: Sequence[int]) -> Array: ...
65
+
66
+ class Mlx(MlxRuntime, Protocol):
67
+ """The MLX module surface consumed by this port, without importing it eagerly."""
68
+
69
+ @property
70
+ def fast(self) -> Fast: ...
71
+
72
+ random: Random
73
+
74
+ def all(self, a: Array, /) -> Array: ...
75
+ def argmin(self, a: Array, /, *, axis: int | None = None) -> Array: ...
76
+ def clear_cache(self) -> None: ...
77
+ def compile[**P, R](self, fun: Callable[P, R], /) -> Callable[P, R]: ...
78
+ def contiguous(self, a: Array, /) -> Array: ...
79
+ def cos(self, a: Array, /) -> Array: ...
80
+ def erf(self, a: Array, /) -> Array: ...
81
+ def exp(self, a: Array, /) -> Array: ...
82
+ def full(self, shape: Sequence[int], vals: object, *, dtype: Dtype) -> Array: ...
83
+ def isfinite(self, a: Array, /) -> Array: ...
84
+ def load(self, file: str) -> dict[str, Array]: ...
85
+ def reciprocal(self, a: Array, /) -> Array: ...
86
+ def sin(self, a: Array, /) -> Array: ...
87
+ def softmax(
88
+ self, a: Array, /, *, axis: int | None = None, precise: bool = False
89
+ ) -> Array: ...
90
+ def sqrt(self, a: Array | float, /) -> Array: ...
91
+ def sum(self, a: Array, /, *, axis: int | None = None, keepdims: bool = False) -> Array: ...
92
+ else:
93
+
94
+ class ArrayConstructor(Protocol):
95
+ pass
96
+
97
+ class TokenizerContract(Protocol):
98
+ pass
99
+
100
+ class MetalKernel(Protocol):
101
+ pass
102
+
103
+ class Fast(Protocol):
104
+ pass
105
+
106
+ class Random(Protocol):
107
+ pass
108
+
109
+ class Mlx(Protocol):
110
+ pass