I have the following code that works on PyTorch 1.11 and fails on 1.13
import torch
print(torch.__version__)
model = torch.jit.load("foo/ranker.pt")
model = model.eval()
x = torch.jit.load("foo/tensor_all.pt")
inputs = list(x.parameters())
for i in inputs:
i.requires_grad = False
model.forward(*inputs)
print("ALL GOOD")
The error that it fails with is
worker_exedir/cruise/mlp/prediction/pytorch/modules/utils/utils.py", line 81, in gather_from_map
map_idx = torch.stack([batch_indices, y_indices, x_indices], dim=-1)
map_features = map[map_idx[..., 0], map_idx[..., 1], map_idx[..., 2], :]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
return map_features
RuntimeError: tensors used as indices must be long, byte or bool tensors
We had the same error in the eager mode and we fixed it.
Is there a way to fix it in a TorchScript without re-training the model?