I’m converting a pytorch model to onnx model. in this model there an assignment of tensor to a slice of another tensor.
when i’m running the converted model with onnxruntime he crashes when trying to assign the small tensor to the big tensor and ignoring the slice operation.
i isolated the problem to this forward function:
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
    x[:y.size(0), 0, :] = y
    return x

onnxruntime returns this error where shape of x is (56,6,256) ans shape of y is (22,256):
The input tensor cannot be reshaped to the requested shape. Input shape:{22,256}, requested shape:{56,1,256}
my env is:

PyTorch Version: 1.5.1
OS (e.g., Linux): Linux ubuntu 16.04
Python version: 3.6.8
onnxruntime verion: 1.4.0

to reproduce this bug just ran this code:
``import torch
import onnx
import onnxruntime
class Test(torch.nn.Module):
def  init (self):
super(). init ()
def forward(self, x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
x[:y.size(0), 0, :] = y
return x
x = torch.zeros((56,6,256))
y = torch.rand((22,256))
m = Test()
torch_outputs = m(x, y)
path = “/tmp/m.onnx”
torch.onnx.export(m, (x, y), path,
do_constant_folding=True,
opset_version=12,
input_names=[“x”, “y”],
output_names=[“z”])
onnx_model = onnx.load_model(path)
onnx.checker.check_model(onnx_model)
inferred_model = onnx.shape_inference.infer_shapes(onnx_model)
onnx.save(inferred_model, path)
ort_model = onnxruntime.InferenceSession(path)
ort_outputs = ort_model.run([“z”], {“x”: x.numpy(), “y”: y.numpy()})``