I want to convert a model that uses in-place index assignment to an onnx model. According to the docs, the conversion doesn’t support in-place index assignment (https://pytorch.org/docs/stable/onnx.html#limitations 1), so I’m trying to rewrite the operation to a scatter operation, but I’m having difficulties doing this.
The current implementation looks something like this:
    for i in range(1, max_dimension):
            combined_tensor[:, num_channels:, i, :, i:] = right_tensor[:, :, :, :-i]

combined_tensor is of shape : (batch_size, num_channels*2, max_dimension, width, height) and right_tensor is of shape (batch_size, num_channels, width, height).
I want to build the indices to supply to the scatter operation, so I’m utilizing meshgrid in this way:
    idx = torch.meshrid(
            range(batch_size),
            range(num_channels, num_channels*2),
            range(max_dimension),
            range(width),
            range(height)[::-1]
        )

But I am unsure if this is the correct approach. Any guidance would be appreciated.