-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Large ending index in Slice operator when exporting to ONNX model #24251
Copy link
Copy link
Closed
Labels
module: onnxRelated to torch.onnxRelated to torch.onnx
Description
When exporting a PyTorch model to ONNX, if the model has the range indices selection operator (e.g. x[2:]) and didn't specify the ending index, the "end" attribute in the exported Slice operator will be an extremely large number. This happens with PyTorch 1.0 1.1 and 1.2. However, in 0.4, there isn't such a case. I wonder if this behavior is intended?
e.g. the model is like this:
class testMod(nn.Module):
def forward(self, x):
return x[2:]
model = testMod()
x = torch.rand(10)
torch.onnx.export(model, x, "slice.onnx", verbose=True, input_names=["input"], output_names=["output"], opset_version = 10)
The exported Slice op is:
%output : Float(8) = onnx::Slice[axes=[0], ends=[**9223372036854775807**], starts=[2]](%input), scope: testMod
If using v0.4 to export, the ending index could be inferred:
%output : Float(8) = onnx::Slice[axes=[0], ends=[**10**], starts=[2]](%input), scope: testMod
Many Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
module: onnxRelated to torch.onnxRelated to torch.onnx