llvm / torch-mlir

The Torch-MLIR project aims to provide first class support from the PyTorch ecosystem to the MLIR ecosystem.
Other
1.31k stars 485 forks source link

No module named 'torch_mlir._mlir_libs._jit_ir_importer' #3691

Open MIONkb opened 2 weeks ago

MIONkb commented 2 weeks ago

I installed torch-mlir with following script in my own conda env, where 20240825.194 is the newest torch-mlir in the url https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels

pip3 install --pre torch-mlir==20240825.194 torchvision \ -f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels \ --extra-index-url https://download.pytorch.org/whl/nightly/cpu

Then I run the torchscript_resnet18_all_output_types.py in /projects/pt1/examples, then error happens:

File "/home/jhlou/Torchmlir/test/simple/torchscript_resnet18_all_output_types.py", line 9, in <module> from torch_mlir import torchscript File "/home/jhlou/anaconda3/lib/python3.11/site-packages/torch_mlir/torchscript.py", line 25, in <module> from torch_mlir.jit_ir_importer import ClassAnnotator, ImportOptions, ModuleBuilder File "/home/jhlou/anaconda3/lib/python3.11/site-packages/torch_mlir/jit_ir_importer/__init__.py", line 14, in <module> from .._mlir_libs._jit_ir_importer import * ModuleNotFoundError: No module named 'torch_mlir._mlir_libs._jit_ir_importer'

Acctually, when I check the anaconda3/lib/python3.11/site-packages/torch_mlir dir, the jit_ir_importer is not in 'torch_mlir._mlir_libs..

How could I install torch-mlir python package correctly? Or did I run it in a wrong way?

This is the "torchscript_resnet18_all_output_types.py"

`

import torch import torchvision

from torch_mlir import torchscript

resnet18 = torchvision.models.resnet18(pretrained=True) resnet18.eval()

module = torchscript.compile(resnet18, torch.ones(1, 3, 224, 224), output_type="torch") print("TORCH OutputType\n", module.operation.get_asm(large_elements_limit=10)) module = torchscript.compile( resnet18, torch.ones(1, 3, 224, 224), output_type="linalg-on-tensors" ) print( "LINALG_ON_TENSORS OutputType\n", module.operation.get_asm(large_elements_limit=10) )

module = torchscript.compile(resnet18, torch.ones(1, 3, 224, 224), output_type="tosa") print("TOSA OutputType\n", module.operation.get_asm(large_elements_limit=10))

`

AmosLewis commented 2 weeks ago

will be fixed by https://github.com/llvm/torch-mlir/pull/3693

MIONkb commented 2 weeks ago

will be fixed by #3693

Thanks a lot!