0
I have the following code:
@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) <- error
That throws:
RuntimeError: shape '[2]' is invalid for input of size 1
Because, given the documentation:
.. warning::
This overload is not supported by TorchScript, and using it in a
Torchscript program will cause undefined behavior.
So the question is, what’s the alternative for use?