deserialize¶
Reconstruct a Tensor from a dict previously produced by serialize.
deserialize
¶
Reconstruct a Tensor from a dict previously produced by serialize.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
Dict previously produced by |
required |
device
|
str or device
|
Device to place all tensors (data blocks and intertwiner weights) on.
Defaults to |
'cpu'
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Reconstructed Tensor with all blocks on device. |
Examples:
Description¶
deserialize is the inverse of serialize. It reads the
plain dict produced by serialize (or loaded from disk via
torch.load(..., weights_only=True)) and reconstructs the original Tensor,
including all indices, block data, and — for non-Abelian tensors — intertwiner
weights.
All torch.Tensor values in the result are placed on device.
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
data |
dict |
— | Dict previously produced by serialize. |
device |
str or torch.device |
"cpu" |
Device to place all block data and intertwiner weights on. |
Returns¶
Tensor — Fully reconstructed tensor with all blocks on device.
Raises¶
ValueError — If version from data["version"] is not supported.
Notes¶
deviceapplies to both block data tensors ("data") and intertwiner weight tensors ("intw"), if present.- For non-Abelian tensors, reconstruction of the CG data is delegated to
nicole.symmetry.delegate.deserialize. - The
dtypeis stored in the serialized dict and applied to all tensors on reconstruction; no explicitdtypeargument is needed.
Examples¶
Basic load from disk¶
import torch
from nicole import deserialize
payload = torch.load("tensor.tnsr", weights_only=True)
t = deserialize(payload)
Load to GPU¶
Round-trip in memory¶
See Also¶
- serialize: Convert a
Tensorto a serializable dict - Examples: Serialization
- Tensor: Main tensor class