Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to lower torch model to TOSA #3935

Open
kslavka-gsi opened this issue Dec 30, 2024 · 0 comments
Open

Failing to lower torch model to TOSA #3935

kslavka-gsi opened this issue Dec 30, 2024 · 0 comments

Comments

@kslavka-gsi
Copy link

Hi,
I am struggling to convert a Torch.nn.Model to TOSA MLIR with the latest torch_mlir builds.
With the torch_mlir snapshot from 27/Jan/2024 the following code works and generates a proper .mlir file.
However, with the latest nightly builds, the .compile is not recogized.
Please suggest how to use the latest torch_mlir to and convert a torch model to TOSA dialect.

import torch
import torch_mlir

class Wrapper(torch.nn.Module):
    def __init__(self) -> None:
        super().__init__()
    
    def forward(self, x, y):
        self.res = torch.add(x,y)
        return self.res

model = Wrapper()
model.eval()
out_tosa_mlir_path = "./vecadd_tosa.mlir"
x = torch.randn(64 * 1024)
y = torch.randn(64 * 1024)
alpha = 2

module = torch_mlir.compile(model, [x,y],output_type=torch_mlir.OutputType.TOSA, use_tracing=True)
with open(out_tosa_mlir_path, "w", encoding="utf-8") as outf:
    outf.write(str(module))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant