blob: 0f1066887e749f868a75de55bb51be651bb67033 [file] [log] [blame] [view]
Scott Todd1a7a4062021-09-01 17:14:53 -07001# IREE Benchmarks
2
3This directory contains configuration definition for IREE's continuous
4benchmarks suite. Benchmark results are posted to https://perf.iree.dev.
5
6The https://buildkite.com/iree/iree-benchmark Buildkite pipeline runs on each
7commit to the `main` branch and posts those results to the dashboard. The
8pipeline also runs on pull requests with the `buildkite:benchmark` label,
9posting results compared against their base commit as comments.
10
11## Types of benchmarks
12
13```
Scott Todd1a7a4062021-09-01 17:14:53 -070014└── TFLite
Lei Zhang1a8360c2022-02-28 13:35:51 -050015 * Models originally in TensorFlow Lite Flatbuffer format and imported with `iree-import-tflite`
Scott Todd1a7a4062021-09-01 17:14:53 -070016```
17
18## Adding new benchmarks
19
20### Machine learning model latency
21
221. Pick the model you want to benchmark and find its source, which could be
23 a Python script, TensorFlow SavedModel from https://tfhub.dev/, TensorFlow
24 Lite FlatBuffer, or some other format with a supported path into IREE. The
25 model can optionally include trained weights if those are important for
26 benchmarking.
27
Lei Zhang1a8360c2022-02-28 13:35:51 -0500282. If this is a TFLite Flatbuffer, the benchmark flow can automatically import
29 it into the corresponding MLIR file. Otherwise, manually import the model
30 into an MLIR file that IREE can compile using the corresponding import tool.
31 For example, `iree-import-tf` for TensorFlow SavedModels. Take notes for where
Scott Todd1a7a4062021-09-01 17:14:53 -070032 the model came from and how it was imported in case the MLIR file needs to
33 be regenerated in the future.
34
Lei Zhang1a8360c2022-02-28 13:35:51 -0500353. Package the source model or imported MLIR file file(s) for storage (see
Scott Todd1a7a4062021-09-01 17:14:53 -070036 [iree_mlir_benchmark_suite.cmake](../build_tools/cmake/iree_mlir_benchmark_suite.cmake)
37 and [download_file.py](../scripts/download_file.py)), then upload them to the
38 `iree-model-artifacts` Google Cloud Storage bucket with the help of a team
39 member. Files currently hosted in that bucket can be viewed at
40 https://storage.googleapis.com/iree-model-artifacts/index.html.
41
424. Edit the appropriate `CMakeLists.txt` file under this directory to include
43 your desired benchmark configuration with the `iree_mlir_benchmark_suite`
44 function. You can test your change by running the
45 https://buildkite.com/iree/iree-benchmark pipeline on a GitHub pull request
46 with the `buildkite:benchmark` label.
47
485. Once your changes are merged to the `main` branch, results will start to
49 appear on the benchmarks dashboard at https://perf.iree.dev.
50
51### Other project metrics
52
53TODO(#6161): Collect metrics for miscellaneous IREE system states
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080054
55## Developer notes
56
57These are ad-hoc notes added for developers to help triage errors.
58
59### Repro of TFLite model errors
60
Lei Zhang1a8360c2022-02-28 13:35:51 -050061These steps help reproduce the failures in TFLite models.
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080062
Lei Zhang1a8360c2022-02-28 13:35:51 -0500631. Install `iree-import-tflite`.
64 ```
65 $ python -m pip install iree-tools-tflite -f https://github.com/google/iree/releases
66 ```
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080067
Lei Zhang1a8360c2022-02-28 13:35:51 -0500682. Expose and confirm the binary `iree-import-tflite` is in your path by running
69 ```
70 $ iree-import-tflite --help
71 ```
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080072
Lei Zhang1a8360c2022-02-28 13:35:51 -0500733. Download the TFLite flatbuffer for the failing benchmarks. The location can
74 be found from [this CMakeLists.txt file](./TFLite/CMakeLists.txt).
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080075
Lei Zhang1a8360c2022-02-28 13:35:51 -0500764. Import the TFLite model into MLIR format using:
77 ```
78 $ iree-import-tflite <tflite-file> -o <mlir-output-file>
79 ```
MaheshRavishankare9ad2cd2021-12-21 14:58:04 -080080
Lei Zhang1a8360c2022-02-28 13:35:51 -0500815. Then compile the input MLIR file with `iree-translate`. The exact flags used
82 to compile and run the benchmarks can be found in
83 [this CMakeLists.txt file](./TFLite/CMakeLists.txt).