Код: Выделить всё
@torch.jit.script
def my_function(t: torch.Tensor) -> torch.Tensor:
if t.dtype != torch.bfloat16:
raise ValueError("Input tensor must be of dtype torch.bfloat16")
int_type = torch.int16
t_bits = t.view(int_type)
Подробнее здесь: [url]https://stackoverflow.com/questions/79252519/pytorch-torchscript-tensor-view-alternative[/url]
Мобильная версия