blosc2.unpack_tensor#
- blosc2.unpack_tensor(cframe: bytes) tensorflow.Tensor | torch.Tensor | np.ndarray #
Unpack (decompress) a packed TensorFlow or PyTorch via a cframe.
- Parameters:
cframe¶ (bytes) – The packed tensor to be restored.
- Returns:
out – The unpacked TensorFlow or PyTorch tensor or NumPy array.
- Return type:
tensor or np.ndarray
- Raises:
TypeError – If
cframe
is not of type bytes, or not a cframe.RunTimeError – If some other problem is detected.
Examples
>>> import os >>> import numpy as np >>> th = np.arange(1e3, dtype=np.float32) >>> cframe = blosc2.pack_tensor(th) >>> if not os.getenv("BTUNE_TRADEOFF"): ... assert len(cframe) < th.size * th.itemsize ... >>> th2 = blosc2.unpack_tensor(cframe) >>> a = np.asarray(th) >>> a2 = np.asarray(th2) >>> np.array_equal(a, a2) True
See also