Skip to content

Commit ab299c2

Browse files
committed
Add note about MLIR compiled outputs in dev docs
Adding an example on how to extract MLIR output from the compilation process in various different formats to the development documentation. This should help developers trying to either debug torch_mlir or use it for the purpose of extracting MLIR outputs for other testing. Fixes #1175
1 parent f83a905 commit ab299c2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

development.md

+22
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,28 @@ cmake --build build
120120
export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/examples
121121
```
122122

123+
## Testing MLIR output in various dialects
124+
125+
To test the compiler's output to the different MLIR dialects, you can use the example `examples/torchscript_resnet18_all_output_types.py`.
126+
127+
Make sure you have activated the virtualenv and set the `PYTHONPATH` above:
128+
```shell
129+
source mlir_venv/bin/activate
130+
export PYTHONPATH=`pwd`/build/tools/torch-mlir/python_packages/torch_mlir:`pwd`/examples
131+
python examples/torchscript_resnet18_all_output_types.py
132+
```
133+
134+
This will display the Resnet18 network example in three dialects: TORCH, LINALG on TENSORS and TOSA.
135+
136+
The main functionality is on `torch_mlir.compile()`'s `output_type`.
137+
138+
Ex:
139+
```python
140+
module = torch_mlir.compile(resnet18, torch.ones(1, 3, 224, 224), output_type="torch")
141+
```
142+
143+
Currently, `output_type` can be: `TORCH`, `TOSA`, `LINALG_ON_TENSORS`, `RAW` and `MHLO`.
144+
123145
## Jupyter
124146

125147
Jupyter notebook:

0 commit comments

Comments
 (0)