• Hi all, I started to explore the torch_mlir utilities, and try to lower to MLIR from pytorch. • As far as I can tell the only/stable way to convert pytorch models using torch_mlir is by using the fx importer export_and_import , e.g: import torchvision.models as models from torch_mlir import fx resnet18 = models.resnet18(pretrained=True).eval() module = fx.export_and_import( resnet18, torch.ones(1, 3, 224, 224), output_type=“tosa”, func_name=resnet18.class.name, ) I tried different “output_type”: torch, linalg_on_tensors, tosa, stablehlo. • Everytime it generates the expected mlir. • My question is: Is there a way to externalize/separate the weights from the MLIR module as the generated output is obviously huge, since it contains weights directly attached to the operations ? • Something similar to the option -externalize-params provided by iree-import-onxx ? • Thanks, Externalize to what?

Article Summaries:

  • Hi all, I started to explore the torch_mlir utilities, and try to lower to MLIR from pytorch. As far as I can tell the only/stable way to convert pytorch models using torch_mlir is by using the fx importer export_and_import , e.g: import torchvision.models as models from torch_mlir import fx resnet18 = models.resnet18(pretrained=True).eval() module = fx.export_and_import( resnet18, torch.ones(1, 3, 224, 224), output_type=“tosa”, func_name=resnet18.class.name, ) I tried different “output_type”: torch, linalg_on_tensors, tosa, stablehlo. Everytime it generates the expected mlir. My quest

Sources: