Skip to content

Does torch_mlir.compile exist now? #4097

@alphin-tosil

Description

@alphin-tosil

I was trying to build and run a pytorch based project code. But I'm facing some errors.
I'm attaching the code:
`
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)

`

I'm also attaching the error that i'm facing:
Traceback (most recent call last): File "/home/tos/COMPILER_PROJECT_DEC_2024/torch-mlir/sample.py", line 21, in <module> mlir_module = torch_mlir.compile(model, (example_input,), output_type="torch") ^^^^^^^^^^^^^^^^^^ AttributeError: module 'torch_mlir' has no attribute 'compile'

Can someone suggest me a solution to fix this issue ?

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