Skip to content

Commit 18899a3

Browse files
[IREE] Inference & Benchmark (#590)
1 parent ec4106e commit 18899a3

34 files changed

+1612
-7
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ DLI supports inference using the following frameworks:
3232
- [RKNN][rknn] (C++ API).
3333
- [ncnn][ncnn] (Python API).
3434
- [PaddlePaddle][PaddlePaddle] (Python API).
35-
- [ExecuTorch][executorch] (C++ and Python APIs)
35+
- [ExecuTorch][executorch] (C++ and Python APIs).
36+
- [IREE][iree] (Python API).
3637

3738
More information about DLI is available on the web-site
3839
([here][dli-ru-web-page] (in Russian)
@@ -105,6 +106,7 @@ Please consider citing the following papers.
105106
for TensorFlow.
106107
- `TensorFlowLite` is a directory of Dockerfiles for TensorFlow Lite.
107108
- `TVM` is a directory of Dockerfiles for Apache TVM.
109+
- `IREE` is a directory of Dockerfiles for IREE.
108110

109111
- `docs` directory contains auxiliary documentation. Please, find
110112
complete documentation at the [Wiki page][dli-wiki].
@@ -158,6 +160,9 @@ Please consider citing the following papers.
158160
- [`validation_results_tvm.md`](results/validation/validation_results_tvm.md)
159161
is a table that confirms correctness of inference implementation
160162
based on Apache TVM for several public models.
163+
- [`validation_results_iree.md`](results/validation/validation_results_iree.md)
164+
is a table that confirms correctness of inference implementation
165+
based on IREE for several public models.
161166

162167
- [`mxnet_models_checklist.md`](results/mxnet_models_checklist.md) contains a list
163168
of deep models inferred by MXNet checked in the DLI benchmark.
@@ -179,6 +184,8 @@ Please consider citing the following papers.
179184
of deep models inferred by TensorFlow Lite checked in the DLI benchmark.
180185
- [`tvm_models_checklist.md`](results/tvm_models_checklist.md) contains a list
181186
of deep models inferred by Apache TVM checked in the DLI benchmark.
187+
- [`iree_models_checklist.md`](results/iree_models_checklist.md) contains a list
188+
of deep models inferred by IREE checked in the DLI benchmark.
182189

183190
- `src` directory contains benchmark sources.
184191

@@ -282,6 +289,7 @@ Report questions, issues and suggestions, using:
282289
[ncnn]: https://github.com/Tencent/ncnn
283290
[PaddlePaddle]: https://www.paddlepaddle.org.cn/en
284291
[executorch]: https://pytorch.org/executorch-overview
292+
[iree]: https://iree.dev
285293
[benchmark-app]: https://github.com/openvinotoolkit/openvino/tree/master/samples/cpp/benchmark_app
286294
[dli-ru-web-page]: http://hpc-education.unn.ru/dli-ru
287295
[dli-web-page]: http://hpc-education.unn.ru/dli

docker/IREE/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM ubuntu_for_dli
2+
3+
# Install IREE
4+
ARG IREE_VERSION=3.8.0
5+
RUN python3 -m pip install iree-base-compiler==${IREE_VERSION} iree-base-runtime==${IREE_VERSION} iree-turbine==${IREE_VERSION}
6+
7+
# Install dependencies
8+
RUN python3 -m pip install opencv-python numpy
9+
10+
# Install onnx for model conversion
11+
ARG ONNX_VERSION=1.19.1
12+
RUN python3 -m pip install onnx==${ONNX_VERSION}
13+
14+
# Install torch for model conversion
15+
ARG TORCH_VERSION=2.9.1
16+
ARG TORCHVISION_VERSION=0.24.1
17+
RUN python3 -m pip install torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION}
18+
19+
WORKDIR /tmp/

requirements_frameworks.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ dglgo==0.0.2
1818
tflite
1919

2020
paddleslim==2.6.0
21-
paddlepaddle==2.6.0
21+
paddlepaddle==2.6.2
2222
--extra-index-url https://mirror.baidu.com/pypi/simple
2323

2424
ncnn
2525
spektral==1.3.0
26+
27+
iree-base-compiler==3.8.0
28+
iree-base-runtime==3.8.0
29+
iree-turbine==3.8.0

results/iree_models_checklist.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Model validation and performance analysis status for IREE
2+
3+
## The list of models is from [TorchVision][torchvision] or [ONNX Model Zoo][onnx].
4+
5+
### Image classification
6+
7+
Model | Availability in [TorchVision][torchvision] (0.24) or [ONNX Model Zoo][onnx] (2025.11.28) | Availability in the validation table |
8+
-|-|-|
9+
densenet-121|+|+|
10+
efficientnet-b0|+|+|
11+
googlenet|+|+|
12+
resnet50|+|+|
13+
squeezenet1_1|+|+|
14+
15+
16+
<!-- LINKS -->
17+
[torchvision]: https://pytorch.org/vision/stable/models.html
18+
[onnx]: https://github.com/onnx/models
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Validation results for the models inferring using IREE
2+
3+
## Public models
4+
5+
We infer models using the following APIs:
6+
7+
1. IREE, when we load PyTorch models directly from source format.
8+
9+
```bash
10+
python inference_iree.py -t classification -is 1 3 224 224 \
11+
-mn densenet121 \
12+
-tm torchvision.models \
13+
-f pytorch \
14+
-i data/ \
15+
--norm --mean 0.485 0.456 0.406 --std 0.229 0.224 0.225 \
16+
-l labels/image_net_synset.txt \
17+
--layout NCHW --channel_swap 2 1 0 \
18+
-fn main
19+
```
20+
21+
1. IREE, when we load ONNX models directly from source format.
22+
23+
```bash
24+
python inference_iree.py -t classification -is 1 3 224 224 \
25+
-mn densenet121 \
26+
-m densenet121.onnx \
27+
-f onnx \
28+
--onnx_opset_version 18 \
29+
-i data/ \
30+
--norm --mean 0.485 0.456 0.406 --std 0.229 0.224 0.225 \
31+
-l labels/image_net_synset.txt \
32+
--layout NCHW --channel_swap 2 1 0 \
33+
-fn main_graph
34+
```
35+
36+
1. PyTorch as source framework for reference.
37+
38+
```bash
39+
python inference_pytorch.py -t classification -is [1,3,224,224] \
40+
--input_names data \
41+
-mn densenet121 \
42+
-mm torchvision.models \
43+
-i data/ \
44+
--mean [123.675,116.28,103.53] \
45+
--input_scale [58.395,57.12,57.375] \
46+
-l labels/image_net_synset.txt
47+
```
48+
49+
### Notes
50+
51+
1. Models in ONNX format loaded from [onnx/models][onnx-models] repository.
52+
1. The model `squeezenet1.1` is missed in [onnx/models][onnx-models] repository.
53+
54+
### Image classification
55+
56+
#### Test image #1
57+
58+
Data source: [ImageNet][imagenet]
59+
60+
Image resolution: 709 x 510
61+

62+
<div style='float: center'>
63+
<img width="150" src="images\ILSVRC2012_val_00000023.JPEG"></img>
64+
</div>
65+
66+
Model | Source Framework | Python API (source framework) | Python API (IREE, PyTorch) | Python API (IREE, ONNX) |
67+
-|-|-|-|-|
68+
densenet-121 | PyTorch | 0.9525911 Granny Smith<br>0.0132309 orange <br>0.0123391 lemon <br>0.0028140 banana <br>0.0020238 piggy bank, penny bank | 0.9523347 Granny Smith<br>0.0132272 orange<br>0.0125170 lemon<br>0.0027910 banana<br>0.0020333 piggy bank, penny bank | 0.9523349 Granny Smith<br>0.0132271 orange<br>0.0125169 lemon<br>0.0027909 banana<br>0.0020333 piggy bank, penny bank |
69+
efficientnet-b0 | PyTorch | 0.3421609 Granny Smith<br />0.1089311 piggy bank, penny bank <br />0.0693323 teapot <br />0.0249018 vase <br />0.0205339 saltshaker, salt shaker | 0.3421628 Granny Smith<br>0.1089310 piggy bank, penny bank<br>0.0693315 teapot<br>0.0249016 vase<br>0.0205339 saltshaker, salt shaker | 0.3421622 Granny Smith<br>0.1089308 piggy bank, penny bank<br>0.0693314 teapot<br>0.0249017 vase<br>0.0205338 saltshaker, salt shaker |
70+
googlenet-v1 | PyTorch | 0.5399834 Granny Smith<br>0.1101810 piggy bank, penny bank <br>0.0232574 vase <br>0.0213452 pitcher, ewer <br>0.0198953 bell pepper | 0.5432554 Granny Smith<br>0.1103971 piggy bank, penny bank<br>0.0232568 vase<br>0.0213901 pitcher, ewer<br>0.0196196 bell pepper | 0.5432543 Granny Smith<br>0.1103970 piggy bank, penny bank<br>0.0232569 vase<br>0.0213901 pitcher, ewer<br>0.0196196 bell pepper |
71+
resnet-50 | PyTorch | 0.9280675 Granny Smith<br />0.0129466 orange <br />0.0058861 lemon <br />0.0041993 necklace <br />0.0025445 banana | 0.9278086 Granny Smith<br>0.0129410 orange<br>0.0059573 lemon<br>0.0042141 necklace<br>0.0025712 banana | 0.4216066 Granny Smith<br>0.0661015 dumbbell<br>0.0348192 barbell<br>0.0049673 orange<br>0.0045203 syringe |
72+
squeezenet1.1 | PyTorch | 0.5913458 piggy bank, penny bank<br />0.0682889 Granny Smith <br />0.0610993 lemon <br />0.0596012 necklace <br />0.0492096 bucket, pail | 0.5895361 piggy bank, penny bank<br>0.0677933 Granny Smith<br>0.0610654 necklace<br>0.0610450 lemon<br>0.0490914 bucket, pail | - |
73+
74+
#### Test image #2
75+
76+
Data source: [ImageNet][imagenet]
77+
78+
Image resolution: 500 x 500
79+

80+
<div style='float: center'>
81+
<img width="150" src="images\ILSVRC2012_val_00000247.JPEG">
82+
</div>
83+
84+
Model | Source Framework | Python API (source framework) | Python API (IREE, PyTorch) | Python API (IREE, ONNX) |
85+
-|-|-|-|-|
86+
densenet-121 | PyTorch | 0.9847536 junco, snowbird<br />0.0068679 chickadee <br />0.0034511 brambling, Fringilla montifringilla <br />0.0015685 water ouzel, dipper <br />0.0012343 indigo bunting, indigo finch, indigo bird, Passerina cyanea | 0.9841590 junco, snowbird<br>0.0072199 chickadee<br>0.0034962 brambling, Fringilla montifringilla<br>0.0016226 water ouzel, dipper<br>0.0012858 indigo bunting, indigo finch, indigo bird, Passerina cyanea | 0.9841590 junco, snowbird<br>0.0072199 chickadee<br>0.0034962 brambling, Fringilla montifringilla<br>0.0016226 water ouzel, dipper<br>0.0012858 indigo bunting, indigo finch, indigo bird, Passerina cyanea |
87+
efficientnet-b0 | PyTorch | 0.8903497 junco, snowbird<br />0.0147084 water ouzel, dipper <br />0.0074830 chickadee <br />0.0044766 brambling, Fringilla montifringilla <br />0.0027406 goldfinch, Carduelis carduelis | 0.8903519 junco, snowbird<br>0.0147081 water ouzel, dipper<br>0.0074829 chickadee<br>0.0044765 brambling, Fringilla montifringilla<br>0.0027406 goldfinch, Carduelis carduelis | 0.8903498 junco, snowbird<br>0.0147084 water ouzel, dipper<br>0.0074830 chickadee<br>0.0044766 brambling, Fringilla montifringilla<br>0.0027406 goldfinch, Carduelis carduelis |
88+
googlenet-v1 | PyTorch | 0.6449553 junco, snowbird<br />0.0752306 chickadee <br />0.0480572 brambling, Fringilla montifringilla <br />0.0298399 goldfinch, Carduelis carduelis <br />0.0126128 house finch, linnet, Carpodacus mexicanus | 0.6461055 junco, snowbird<br>0.0772564 chickadee<br>0.0468782 brambling, Fringilla montifringilla<br>0.0295897 goldfinch, Carduelis carduelis<br>0.0123322 house finch, linnet, Carpodacus mexicanus | 0.6461049 junco, snowbird<br>0.0772565 chickadee<br>0.0468783 brambling, Fringilla montifringilla<br>0.0295897 goldfinch, Carduelis carduelis<br>0.0123323 house finch, linnet, Carpodacus mexicanus |
89+
resnet-50 | PyTorch | 0.9809760 junco, snowbird<br />0.0049167 goldfinch, Carduelis carduelis <br />0.0036987 chickadee <br />0.0036697 water ouzel, dipper <br />0.0029304 brambling, Fringilla montifringilla | 0.9805012 junco, snowbird<br>0.0049154 goldfinch, Carduelis carduelis<br>0.0039196 chickadee<br>0.0038098 water ouzel, dipper<br>0.0028983 brambling, Fringilla montifringilla | 0.3845567 junco, snowbird<br>0.0091156 water ouzel, dipper<br>0.0054526 chickadee<br>0.0026206 indigo bunting, indigo finch, indigo bird, Passerina cyanea<br>0.0023612 brambling, Fringilla montifringilla |
90+
squeezenet1.1 | PyTorch | 0.9609295 junco, snowbird<br />0.0248581 chickadee <br />0.0042597 brambling, Fringilla montifringilla <br />0.0037157 goldfinch, Carduelis carduelis <br />0.0033528 ruffed grouse, partridge, Bonasa umbellus | 0.9614577 junco, snowbird<br>0.0250981 chickadee<br>0.0040701 brambling, Fringilla montifringilla<br>0.0035156 goldfinch, Carduelis carduelis<br>0.0030858 ruffed grouse, partridge, Bonasa umbellus | - |
91+
92+
#### Test image #3
93+
94+
Data source: [ImageNet][imagenet]
95+
96+
Image resolution: 333 x 500
97+

98+
<div style='float: center'>
99+
<img width="150" src="images\ILSVRC2012_val_00018592.JPEG">
100+
</div>
101+
102+
Model | Source Framework | Python API (source framework) | Python API (IREE, PyTorch) | Python API (IREE, ONNX) |
103+
-|-|-|-|-|
104+
densenet-121 | PyTorch | 0.3047960 liner, ocean liner<br />0.1327189 breakwater, groin, groyne, mole, bulwark, seawall, jetty <br />0.1180288 container ship, containership, container vessel <br />0.0794686 drilling platform, offshore rig <br />0.0718431 dock, dockage, docking facility | 0.3022414 liner, ocean liner<br>0.1322474 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.1194614 container ship, containership, container vessel<br>0.0795042 drilling platform, offshore rig<br>0.0723073 dock, dockage, docking facility | 0.3022407 liner, ocean liner<br>0.1322481 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.1194605 container ship, containership, container vessel<br>0.0795041 drilling platform, offshore rig<br>0.0723069 dock, dockage, docking facility |
105+
efficientnet-b0 | PyTorch | 0.4476882 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br />0.0953832 container ship, containership, container vessel <br />0.0872342 beacon, lighthouse, beacon light, pharos <br />0.0559825 drilling platform, offshore rig <br />0.0441807 liner, ocean liner | 0.4476875 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0953838 container ship, containership, container vessel<br>0.0872344 beacon, lighthouse, beacon light, pharos<br>0.0559831 drilling platform, offshore rig<br>0.0441806 liner, ocean liner | 0.4476894 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0953836 container ship, containership, container vessel<br>0.0872341 beacon, lighthouse, beacon light, pharos<br>0.0559827 drilling platform, offshore rig<br>0.0441803 liner, ocean liner |
106+
googlenet-v1 | PyTorch | 0.1330581 liner, ocean liner<br />0.0796951 drilling platform, offshore rig <br />0.0680323 container ship, containership, container vessel <br />0.0588053 breakwater, groin, groyne, mole, bulwark, seawall, jetty <br />0.0365606 fireboat | 0.1323653 liner, ocean liner<br>0.0796393 drilling platform, offshore rig<br>0.0678083 container ship, containership, container vessel<br>0.0585719 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0366882 fireboat | 0.1323648 liner, ocean liner<br>0.0796394 drilling platform, offshore rig<br>0.0678085 container ship, containership, container vessel<br>0.0585720 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0366881 fireboat |
107+
resnet-50 | PyTorch | 0.4818293 liner, ocean liner<br />0.0992477 breakwater, groin, groyne, mole, bulwark, seawall, jetty <br />0.0687505 container ship, containership, container vessel <br />0.0517874 dock, dockage, docking facility <br />0.0483462 pirate, pirate ship | 0.4759648 liner, ocean liner<br>0.1025407 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0689996 container ship, containership, container vessel<br>0.0524496 dock, dockage, docking facility<br>0.0473777 pirate, pirate ship | 0.1220204 lifeboat<br>0.0430796 breakwater, groin, groyne, mole, bulwark, seawall, jetty<br>0.0360478 beacon, lighthouse, beacon light, pharos<br>0.0335465 dock, dockage, docking facility<br>0.0251255 liner, ocean liner |
108+
squeezenet1.1 | PyTorch | 0.4393108 liner, ocean liner<br />0.1895231 container ship, containership, container vessel <br />0.1506845 pirate, pirate ship <br />0.0962459 fireboat <br />0.0199389 drilling platform, offshore rig | 0.4413096 liner, ocean liner<br>0.1931005 container ship, containership, container vessel<br>0.1459103 pirate, pirate ship<br>0.0937753 fireboat<br>0.0198682 drilling platform, offshore rig | - |
109+
110+
<!-- LINKS -->
111+
[imagenet]: http://www.image-net.org
112+
[onnx-models]: https://github.com/onnx/models/tree/main

src/accuracy_checker/process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def execute(self, idx):
2525
command_line = self.__fill_command_line()
2626
if command_line == '':
2727
self.__log.error('Command line is empty')
28-
self.__log.info(f'Start accuracy check for {idx+1} test: {self._test.model.name}')
28+
self.__log.info(f'Start accuracy check for {idx + 1} test: {self._test.model.name}')
2929
self.__log.info(f'Command line is : {command_line}')
3030
self._executor.set_target_framework(self._test.framework)
3131
command_line = self._executor.prepare_command_line(self._test, command_line)

src/benchmark/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ the following frameworks:
2222
- [RKNN][rknn].
2323
- [Spektral][spektral] (Python API).
2424
- [PaddlePaddle][paddlepaddle] (Python API).
25+
- [IREE][iree] (Python API).
2526

2627
### Implemented algorithm
2728

@@ -274,3 +275,4 @@ pip install openvino_dev[mxnet,caffe,caffe2,onnx,pytorch,tensorflow2]==<your ver
274275
[rknn]: https://github.com/rockchip-linux/rknpu2
275276
[spektral]: https://graphneural.network
276277
[paddlepaddle]: https://www.paddlepaddle.org.cn/en
278+
[iree]: https://iree.dev

src/benchmark/config_parser_factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from frameworks.ncnn.ncnn_parameters_parser import NcnnParametersParser
1515
from frameworks.spektral.spektral_parameters_parser import SpektralParametersParser
1616
from frameworks.executorch.executorch_parameters_parser import ExecuTorchParametersParser
17+
from frameworks.iree.iree_parameters_parser import IREEParametersParser
1718

1819

1920
def get_parameters_parser(framework):
@@ -57,4 +58,6 @@ def get_parameters_parser(framework):
5758
return CppParametersParser()
5859
if framework == KnownFrameworks.executorch:
5960
return ExecuTorchParametersParser()
61+
if framework == KnownFrameworks.iree:
62+
return IREEParametersParser()
6063
raise NotImplementedError(f'Unknown framework {framework}')

src/benchmark/frameworks/config_parser/test_reporter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def prepare_framework_params(self):
7777
match_parameter_description['compile_with_backend'] = 'Pytorch compile backend'
7878

7979
match_parameter_description['high_level_api'] = 'TVM HighLevelAPI'
80-
match_parameter_description['opt_level'] = 'TVM OptimizationLevel'
80+
match_parameter_description['opt_level'] = 'Optimization level'
81+
82+
match_parameter_description['extra_compile_args'] = 'Extra compile args'
8183

8284
for parameter, description in match_parameter_description.items():
8385
if hasattr(self.dep_parameters, parameter) and getattr(self.dep_parameters, parameter) is not None:

src/benchmark/frameworks/framework_wrapper_registry.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .rknn.rknn_wrapper import RknnWrapper
2222
from .executorch_cpp.executorch_cpp_wrapper import ExecuTorchCppWrapper
2323
from .executorch.executorch_wrapper import ExecuTorchWrapper
24+
from .iree.iree_wrapper import IREEWrapper
2425

2526

2627
class FrameworkWrapperRegistry(metaclass=Singleton):
@@ -62,3 +63,4 @@ def _get_wrappers(self):
6263
self._framework_wrappers[RknnWrapper.framework_name] = RknnWrapper()
6364
self._framework_wrappers[ExecuTorchCppWrapper.framework_name] = ExecuTorchCppWrapper()
6465
self._framework_wrappers[ExecuTorchWrapper.framework_name] = ExecuTorchWrapper()
66+
self._framework_wrappers[IREEWrapper.framework_name] = IREEWrapper()

0 commit comments

Comments
 (0)