llvm / llvm/torch-mlir

load an MLIR file as a model

Open
#2,109 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.9k
Forks
736
Avg merge
5d 22h
Merged PRs (30d)
15

Description

Hi,
I have translated a model into MLIR as in the examples :

resnet18 = torchvision.models.resnet18(pretrained=True)
resnet18.eval()
module = torch_mlir.compile(resnet18, torch.ones(1, 3, 224, 224), output_type="torch")
print("TORCH OutputType\n", module.operation.get_asm(large_elements_limit=10))

After that, I changed the MLIR and now, I would like to do the opposite and load this MLIR as a module in my python code to continue to compile it like in examples :

backend = refbackend.RefBackendLinalgOnTensorsBackend()
compiled = backend.compile(module)
jit_module = backend.load(compiled)
predictions(resnet18.forward, jit_module.forward, img, labels)

I just need a line between the to code two load the MLIR but I couldn't find anything about it on the internet. Does anyone know how to do it?
Thanks a lot

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the Python examples in the issue and inspect the torch-mlir Python API for MLIR parsing or module-loading entry points. Determine whether an edited MLIR module can be passed to the shown backend.compile and backend.load flow; done means the edited file loads successfully and produces a usable jit_module.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.