Skip to content

named

torch_to_nnef.tensor.named

NamedTensor

NamedTensor(fp_tensor: torch.Tensor, nnef_name: str)

Bases: Tensor

Tensor enriched with name attribute.

data property writable
data

Very important to keep access to all special attr of NamedTensor.

apply_name_to_tensor_in_module

apply_name_to_tensor_in_module(model: torch.nn.Module)

Transform torch.Tensor or Parameters into NamedTensor.

This is applied at export time of torch_to_nnef Just before doing any tracing and allow to keep variable naming identical to PyTorch one

This consistent naming unlock subsequent manipulations such as LORA applications @ inference or such.