Skip to content

[Feature Request][Relax][Torch] Add support for torch.mm (mm.default) in from_exported_program #18339

Closed

Description

@tinywisdom

Expected behavior

  • The frontend should support lowering torch.mm into an equivalent Relax operator (likely relax.op.matmul).

  • At minimum, if unsupported, provide a clearer user-facing error message and possible fallback guidance.

Actual behavior

When converting a PyTorch torch.exported program into TVM Relax using from_exported_program, a model containing torch.mm fails with:

AssertionError: Unsupported function types ['mm.default']

This indicates that the mm.default operator (2D matrix multiply) is currently not supported in the TVM Relax PyTorch frontend.

Environment

  • OS: (Ubuntu 22.04.4 LTS (x86_64))
  • TVM version: (release v0.21.0)
  • Python: (3.10.16)
  • LLVM: (17.0.6)

Steps to reproduce

import torch
import torch.nn as nn
from torch.export import export as torch_export
from tvm.relax.frontend.torch import from_exported_program

class M(nn.Module):
    def forward(self, a, b):
        # Key op: torch.mm (2D matrix multiply)
        return torch.mm(a, b)

def main():
    torch.manual_seed(0)
    m = M().eval()

    # Inputs: (2, 3) @ (3, 4) -> (2, 4)
    a = torch.randn(2, 3, dtype=torch.float32)
    b = torch.randn(3, 4, dtype=torch.float32)

    # 1) Check eager path
    with torch.inference_mode():
        y = m(a, b)
    print("PyTorch eager OK, y.shape =", tuple(y.shape))

    # 2) Export
    ep = torch_export(m, (a, b))
    print("ExportedProgram created.")

    # 3) Import into TVM Relax — triggers unsupported function type
    mod = from_exported_program(ep)

if __name__ == "__main__":
    main()

Triage

  • needs-triage
  • bug

cc @junrushao @shingjan

Activity

  1. added
    needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address it
    on Sep 23, 2025
  2. self-assigned this
    on Sep 25, 2025
  3. MasterJH5574 commented on Sep 25, 2025

    @MasterJH5574
    Contributor

    Completed with #18343 merged in. Thanks @tlopex for working on this!

  4. added a commit that references this issue on Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

needs-triagePRs or issues that need to be investigated by maintainers to find the right assignees to address ittype: bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions