Thanks a lot. but .to is not applicable here. it works in libtorch only if the underlying data is a string (usually used with IValue if I’m not mistaken) other than that, types and devices are other usecases of .to which again are not applicable here. since here we want to turn the whole tensor into a byte representation an not individual elements in it. .to(torch.float, or the likes, only change the underlting data representation and not the tensor itself.
The way to go was to use io.BytesIO() and get the bytes needed.