safetensors 0.5.0__cp38-abi3-win_amd64.whl → 0.5.1__cp38-abi3-win_amd64.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 safetensors might be problematic. Click here for more details.

safetensors/__init__.pyi CHANGED
@@ -5,11 +5,11 @@ def deserialize(bytes):
5
5
  Opens a safetensors lazily and returns tensors as asked
6
6
 
7
7
  Args:
8
- data (:obj:`bytes`):
8
+ data (`bytes`):
9
9
  The byte content of a file
10
10
 
11
11
  Returns:
12
- (:obj:`List[str, Dict[str, Dict[str, any]]]`):
12
+ (`List[str, Dict[str, Dict[str, any]]]`):
13
13
  The deserialized content is like:
14
14
  [("tensor_name", {"shape": [2, 3], "dtype": "F32", "data": b"\0\0.." }), (...)]
15
15
  """
@@ -21,14 +21,14 @@ def serialize(tensor_dict, metadata=None):
21
21
  Serializes raw data.
22
22
 
23
23
  Args:
24
- tensor_dict (:obj:`Dict[str, Dict[Any]]`):
24
+ tensor_dict (`Dict[str, Dict[Any]]`):
25
25
  The tensor dict is like:
26
26
  {"tensor_name": {"dtype": "F32", "shape": [2, 3], "data": b"\0\0"}}
27
- metadata (:obj:`Dict[str, str]`, *optional*):
27
+ metadata (`Dict[str, str]`, *optional*):
28
28
  The optional purely text annotations
29
29
 
30
30
  Returns:
31
- (:obj:`bytes`):
31
+ (`bytes`):
32
32
  The serialized content.
33
33
  """
34
34
  pass
@@ -39,16 +39,16 @@ def serialize_file(tensor_dict, filename, metadata=None):
39
39
  Serializes raw data.
40
40
 
41
41
  Args:
42
- tensor_dict (:obj:`Dict[str, Dict[Any]]`):
42
+ tensor_dict (`Dict[str, Dict[Any]]`):
43
43
  The tensor dict is like:
44
44
  {"tensor_name": {"dtype": "F32", "shape": [2, 3], "data": b"\0\0"}}
45
- filename (:obj:`str`):
45
+ filename (`str`, or `os.PathLike`):
46
46
  The name of the file to write into.
47
- metadata (:obj:`Dict[str, str]`, *optional*):
47
+ metadata (`Dict[str, str]`, *optional*):
48
48
  The optional purely text annotations
49
49
 
50
50
  Returns:
51
- (:obj:`bytes`):
51
+ (`bytes`):
52
52
  The serialized content.
53
53
  """
54
54
  pass
@@ -58,16 +58,92 @@ class safe_open:
58
58
  Opens a safetensors lazily and returns tensors as asked
59
59
 
60
60
  Args:
61
- filename (:obj:`str`):
61
+ filename (`str`, or `os.PathLike`):
62
62
  The filename to open
63
63
 
64
- framework (:obj:`str`):
65
- The framework you want your tensors in. Supported values:
64
+ framework (`str`):
65
+ The framework you want you tensors in. Supported values:
66
66
  `pt`, `tf`, `flax`, `numpy`.
67
67
 
68
- device (:obj:`str`, defaults to :obj:`"cpu"`):
68
+ device (`str`, defaults to `"cpu"`):
69
69
  The device on which you want the tensors.
70
70
  """
71
71
 
72
- def __init__(self, filename, framework, device="cpu"):
72
+ def __init__(filename, framework, device=...):
73
73
  pass
74
+ def __enter__(self):
75
+ """
76
+ Start the context manager
77
+ """
78
+ pass
79
+ def __exit__(self, _exc_type, _exc_value, _traceback):
80
+ """
81
+ Exits the context manager
82
+ """
83
+ pass
84
+ def get_slice(self, name):
85
+ """
86
+ Returns a full slice view object
87
+
88
+ Args:
89
+ name (`str`):
90
+ The name of the tensor you want
91
+
92
+ Returns:
93
+ (`PySafeSlice`):
94
+ A dummy object you can slice into to get a real tensor
95
+ Example:
96
+ ```python
97
+ from safetensors import safe_open
98
+
99
+ with safe_open("model.safetensors", framework="pt", device=0) as f:
100
+ tensor_part = f.get_slice("embedding")[:, ::8]
101
+
102
+ ```
103
+ """
104
+ pass
105
+ def get_tensor(self, name):
106
+ """
107
+ Returns a full tensor
108
+
109
+ Args:
110
+ name (`str`):
111
+ The name of the tensor you want
112
+
113
+ Returns:
114
+ (`Tensor`):
115
+ The tensor in the framework you opened the file for.
116
+
117
+ Example:
118
+ ```python
119
+ from safetensors import safe_open
120
+
121
+ with safe_open("model.safetensors", framework="pt", device=0) as f:
122
+ tensor = f.get_tensor("embedding")
123
+
124
+ ```
125
+ """
126
+ pass
127
+ def keys(self):
128
+ """
129
+ Returns the names of the tensors in the file.
130
+
131
+ Returns:
132
+ (`List[str]`):
133
+ The name of the tensors contained in that file
134
+ """
135
+ pass
136
+ def metadata(self):
137
+ """
138
+ Return the special non tensor information in the header
139
+
140
+ Returns:
141
+ (`Dict[str, str]`):
142
+ The freeform metadata.
143
+ """
144
+ pass
145
+
146
+ class SafetensorError(Exception):
147
+ """
148
+ Custom Python Exception for Safetensor errors.
149
+ """
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: safetensors
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Classifier: Development Status :: 5 - Production/Stable
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: Intended Audience :: Education
@@ -1,5 +1,5 @@
1
- safetensors-0.5.0.dist-info/METADATA,sha256=ayT6ICSu_GWfjkVeNIUo54Gr0oyAeZVzCZXuIZgvUGs,3902
2
- safetensors-0.5.0.dist-info/WHEEL,sha256=mYDPFrpmO1_UhonyEoMo2i0zHOwqc92hj_Q3CYuEBdM,94
1
+ safetensors-0.5.1.dist-info/METADATA,sha256=uFpXvzQlZ9qoi1joyCsHVw35woQhc50dY02xuZxn5OI,3902
2
+ safetensors-0.5.1.dist-info/WHEEL,sha256=mYDPFrpmO1_UhonyEoMo2i0zHOwqc92hj_Q3CYuEBdM,94
3
3
  safetensors/flax.py,sha256=lyCfXWTwOqkKvfIbsfy1lTNoslqZm5RjBvvg6d1ZNZU,3984
4
4
  safetensors/mlx.py,sha256=MfhCBl9M9uW5BnFngRg3CNobi7fZXxS3ulJ9so82cNE,3975
5
5
  safetensors/numpy.py,sha256=HBAwy9bXQIKM_uk328kXiZ8tAIhtiq4usngqAWu_l8Y,5113
@@ -8,6 +8,6 @@ safetensors/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  safetensors/tensorflow.py,sha256=hvOLFjirEm-mZlzKcwbeNZutgcKtUxnaEP2VlrGd-Zc,4027
9
9
  safetensors/torch.py,sha256=8IEyIkBIYLL9lTSqtabsuZspVHgptYYc1X2d8S8AWXs,18325
10
10
  safetensors/__init__.py,sha256=xxEn5gc4JWHjA0wnafb0Wwwq1m2QXwlbm5nsItGRqO0,180
11
- safetensors/__init__.pyi,sha256=C_f5av3UsqpI042F4N3EDdZjeBTahOBcS5aMAArrE7E,2044
12
- safetensors/_safetensors_rust.pyd,sha256=UJmWcxKLUO9QZAnoIvCuckHOE6hRLnKSiJHxxHUqaxs,670720
13
- safetensors-0.5.0.dist-info/RECORD,,
11
+ safetensors/__init__.pyi,sha256=5TwX35SbOMXsbK0srQFQaX2YlIGso4o9V82VJ7nZ-Mc,3899
12
+ safetensors/_safetensors_rust.pyd,sha256=R16hvpW3T5ezix-yFRGi8IBqFC8ByGgIroptMQFm9TQ,670720
13
+ safetensors-0.5.1.dist-info/RECORD,,