ztensor 0.1.0__py3-none-musllinux_1_2_armv7l.whl → 0.1.1__py3-none-musllinux_1_2_armv7l.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 ztensor might be problematic. Click here for more details.
ztensor/__init__.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from .ztensor import ffi, lib
|
|
3
|
+
from ml_dtypes import bfloat16
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
# --- Pythonic Wrapper ---
|
|
@@ -52,7 +53,10 @@ DTYPE_NP_TO_ZT = {
|
|
|
52
53
|
np.dtype('uint64'): 'uint64', np.dtype('uint32'): 'uint32',
|
|
53
54
|
np.dtype('uint16'): 'uint16', np.dtype('uint8'): 'uint8',
|
|
54
55
|
np.dtype('bool'): 'bool',
|
|
56
|
+
# ADDED: Mapping for bfloat16 to handle writing
|
|
57
|
+
np.dtype(bfloat16): 'bfloat16',
|
|
55
58
|
}
|
|
59
|
+
# MODIFIED: Re-construct the reverse mapping
|
|
56
60
|
DTYPE_ZT_TO_NP = {v: k for k, v in DTYPE_NP_TO_ZT.items()}
|
|
57
61
|
|
|
58
62
|
|
|
@@ -90,6 +94,7 @@ class TensorMetadata:
|
|
|
90
94
|
@property
|
|
91
95
|
def dtype(self):
|
|
92
96
|
"""Returns the numpy dtype for this tensor."""
|
|
97
|
+
# This will now correctly return a bfloat16 dtype object when dtype_str is 'bfloat16'
|
|
93
98
|
return DTYPE_ZT_TO_NP.get(self.dtype_str)
|
|
94
99
|
|
|
95
100
|
# RE-ENABLED: This property now works because the underlying FFI functions are available.
|
|
@@ -137,6 +142,12 @@ class Reader:
|
|
|
137
142
|
def read_tensor(self, name: str) -> np.ndarray:
|
|
138
143
|
"""Reads a tensor by name and returns it as a NumPy array (zero-copy)."""
|
|
139
144
|
metadata = self.get_metadata(name)
|
|
145
|
+
|
|
146
|
+
# This check is now more robust.
|
|
147
|
+
dtype = metadata.dtype
|
|
148
|
+
if dtype is None:
|
|
149
|
+
raise ZTensorError(f"Unsupported ztensor dtype: '{metadata.dtype_str}'")
|
|
150
|
+
|
|
140
151
|
view_ptr = lib.ztensor_reader_read_tensor_view(self._ptr, metadata._ptr)
|
|
141
152
|
_check_ptr(view_ptr, f"read_tensor: {name}")
|
|
142
153
|
|
|
@@ -144,9 +155,11 @@ class Reader:
|
|
|
144
155
|
view_ptr = ffi.gc(view_ptr, lib.ztensor_free_tensor_view)
|
|
145
156
|
|
|
146
157
|
# CORRECTED: Create array using the subclass, which handles reshaping and memory.
|
|
158
|
+
# With the correct bfloat16 dtype, np.frombuffer will now correctly interpret
|
|
159
|
+
# the buffer, creating an array with the right number of elements (2048).
|
|
147
160
|
array = _ZTensorView(
|
|
148
161
|
buffer=ffi.buffer(view_ptr.data, view_ptr.len),
|
|
149
|
-
dtype=
|
|
162
|
+
dtype=dtype,
|
|
150
163
|
shape=metadata.shape,
|
|
151
164
|
view_ptr=view_ptr
|
|
152
165
|
)
|
|
@@ -189,6 +202,7 @@ class Writer:
|
|
|
189
202
|
shape_array = np.array(tensor.shape, dtype=np.uint64)
|
|
190
203
|
shape_ptr = ffi.cast("uint64_t*", shape_array.ctypes.data)
|
|
191
204
|
|
|
205
|
+
# The updated DTYPE_NP_TO_ZT will now correctly handle bfloat16 tensors.
|
|
192
206
|
dtype_str = DTYPE_NP_TO_ZT.get(tensor.dtype)
|
|
193
207
|
if not dtype_str:
|
|
194
208
|
raise ZTensorError(f"Unsupported NumPy dtype: {tensor.dtype}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ztensor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -9,6 +9,7 @@ Classifier: Intended Audience :: Developers
|
|
|
9
9
|
Classifier: Topic :: Scientific/Engineering
|
|
10
10
|
Requires-Dist: numpy
|
|
11
11
|
Requires-Dist: cffi
|
|
12
|
+
Requires-Dist: ml-dtypes
|
|
12
13
|
License-File: LICENSE
|
|
13
14
|
Summary: Python bindings for the zTensor library.
|
|
14
15
|
Author: In Gim <in.gim@yale.edu>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
ztensor-0.1.
|
|
2
|
-
ztensor-0.1.
|
|
3
|
-
ztensor-0.1.
|
|
1
|
+
ztensor-0.1.1.dist-info/METADATA,sha256=dpaZnxqi7u30Z3uH641XoVg_DeH5k25UamSBjzseBos,4446
|
|
2
|
+
ztensor-0.1.1.dist-info/WHEEL,sha256=uk6lXffjnM20NjdJS1j5pULyv9smQtZKAlwiwmTYIRE,104
|
|
3
|
+
ztensor-0.1.1.dist-info/licenses/LICENSE,sha256=AoeyV1LzTyOz9sbr6uOzk_P0lW963DvhJHnVNVQlI3Y,1063
|
|
4
4
|
ztensor.libs/libgcc_s-5b5488a6.so.1,sha256=HGKUsVmTeNAxEdSy7Ua5Vh_I9FN3RCbPWzvZ7H_TrwE,2749061
|
|
5
|
-
ztensor/__init__.py,sha256=
|
|
5
|
+
ztensor/__init__.py,sha256=pzpS0XNcpBb762OPUG7-3raEJxz7P99KX6CGAdh-DS0,9086
|
|
6
6
|
ztensor/ztensor/__init__.py,sha256=sIpB0pJYFX20TdZapIoPMxqMz37wKJyxCkAlTemWDq4,140
|
|
7
7
|
ztensor/ztensor/ffi.py,sha256=J7CG26lx0Xu0IjYR7GWev-BDgGQXseKA4cjkh0IhnLE,2746
|
|
8
8
|
ztensor/ztensor/libztensor.so,sha256=9bgmcP7Tj8o3loKKYgTfK6kzL1wcgxoKCTykU6CSvEI,1611249
|
|
9
|
-
ztensor-0.1.
|
|
9
|
+
ztensor-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|