[Python] Is torch_mlir.compile currently part of the official PyTorch or torch-mlir API?

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    I’ve seen references to torch_mlir.compile from several AI tools especially from ChatGPT, DeepSeek, etc. I'm also attaching a sample code based on the scenario.

    import torch
    import torch_mlir

    # Define a simple PyTorch model
    class SimpleModel(torch.nn.Module):
    def __init__(self):
    super(SimpleModel, self).__init__()
    self.linear = torch.nn.Linear(3, 2)

    def forward(self, x):
    return self.linear(x)

    # Create an instance of the model
    model = SimpleModel()
    model.eval() # Set model to evaluation mode

    # Create example input tensor
    example_input = torch.randn(1, 3)

    # Compile the model using Torch-MLIR
    mlir_module = torch_mlir.compile(model, (example_input,), output_type="torch")

    # Print the MLIR output
    print(mlir_module)


    Is torch_mlir.compile an officially supported function in the latest versions of PyTorch or torch-mlir, or is it outdated or renamed?

    I’d appreciate a clear answer based on the current state of the API.

    Continue reading...

Compartilhe esta Página