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"
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))
`