Skip to content

torch.export with nn.Transformer creates a non-contiguous memory tensor for aten.view #4285

@yushangdi

Description

@yushangdi

There is an issue in pytorch/pytorch repo (pytorch/pytorch#159126) reporting an issue with using torch.export.export with torch_mlir on a transformer layer model.

After looking into it a bit more, the exported model itself appears to be fine on the PyTorch side. I'm re-posting here in case someone with more experience on the torch-mlir side might have thoughts on how to address this.

error message:

/lib/python3.11/site-packages/torch/_refs/__init__.py", line 3754, in _reshape_view_helper
    raise ValueError(msg)
ValueError: Cannot view a tensor with shape torch.Size([10, 4, 1, 64]) and strides (64, 640, 640, 1) as a tensor with shape (40, 64)!
While executing %view_12 : [num_users=1] = call_function[target=torch.ops.aten.view.default](args = (%permute, [40, 64]), kwargs = {})

Please see the original issue for more details, including repro steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions