Skip to content

bug in onnx export of aten_repeat_interleave_self_int results in incorrect code #2932

@bas-aarts

Description

@bas-aarts

running this script:

import onnx
import torch

class MyModule(torch.nn.Module):
    def forward(self):
        return torch.repeat_interleave(torch.tensor([2]), 2, 0)

model = MyModule()
model.eval()
with torch.no_grad():
    torch.onnx.export(model, (), optimize=False).save("output.onnx")
onnx.shape_inference.infer_shapes_path("output.onnx", strict_mode=True)

results in the following error:

onnx.onnx_cpp2py_export.shape_inference.InferenceError: [ShapeInferenceError] Inference error(s): (op_type:Identity, node name: node_repeat_interleave): [ShapeInferenceError] Inferred shape and existing shape differ in rank: (2) vs (1)

the issue is this line of code

.
This line checks the original rank, and not the current rank. It should therefore be:
if self_rank == 0:

versions of relevant packages:

onnx                          1.20.0
onnx-ir                       0.2.1
onnxscript                    0.7.0
torch                         2.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    contribution welcomeWe welcome code contributions for thismodule: torchlibRelated to the torch/aten function lib in development

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions