fhelium.core.tensor_resident
Tensor storage, device transfer, and byte accounting for exact values.
TensorResident
class View source
TensorResident()Bases: ABC
An exact FHElium value whose declared tensor fields move together.
Subclasses enumerate their direct tensor fields and reconstruct the same exact value state around replacement tensors. The capability exposes one common device, logical payload bytes, unique backing-storage bytes, and functional movement for one value.
TensorResident values expose ordinary PyTorch tensors. Functional movement creates independent storage when copy=True and leaves the source object accessible to its caller.
device
property
device: torch.deviceCommon device of every declared tensor field.
nbytes
property
nbytes: intLogical tensor payload bytes, counting every declared tensor field.
storage_nbytes
property
storage_nbytes: intBytes in unique backing storages referenced by declared tensors.
This differs from nbytes when tensor fields share storage or a view references a backing allocation larger than its logical payload. It remains a tensor-storage measure, not CUDA allocator reservation or process memory reported by NVML.
is_cpu
property
is_cpu: boolWhether all declared tensors reside on CPU.
is_cuda
property
is_cuda: boolWhether all declared tensors reside on one CUDA device.
is_pinned
property
is_pinned: boolWhether every declared tensor uses pinned CPU storage.
CUDA values return False. A CPU value whose fields mix pageable and pinned storage also returns False; managed residency validates and rejects such mixed materializations rather than treating them as pageable.
to
method
def to(device: torch.device | str, *, non_blocking: bool=False, copy: bool=False) -> Self: ...Functionally move all declared tensors to one PyTorch device.
cpu
method
def cpu(*, copy: bool=False) -> Self: ...Return this exact value in ordinary pageable CPU storage.
pin_memory
method
def pin_memory(*, copy: bool=False) -> Self: ...Return this exact value backed by pinned CPU tensor storage.
Parameters
copy: Create independent pinned storage even when every source tensor is already pinned. WithFalse, an already uniformly pinned CPU value is returned unchanged.