Scott Todd | 1a7a406 | 2021-09-01 17:14:53 -0700 | [diff] [blame] | 1 | # IREE Benchmarks |
| 2 | |
| 3 | This directory contains configuration definition for IREE's continuous |
| 4 | benchmarks suite. Benchmark results are posted to https://perf.iree.dev. |
| 5 | |
| 6 | The https://buildkite.com/iree/iree-benchmark Buildkite pipeline runs on each |
| 7 | commit to the `main` branch and posts those results to the dashboard. The |
| 8 | pipeline also runs on pull requests with the `buildkite:benchmark` label, |
| 9 | posting results compared against their base commit as comments. |
| 10 | |
| 11 | ## Types of benchmarks |
| 12 | |
| 13 | ``` |
Scott Todd | 1a7a406 | 2021-09-01 17:14:53 -0700 | [diff] [blame] | 14 | └── TFLite |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 15 | * Models originally in TensorFlow Lite Flatbuffer format and imported with `iree-import-tflite` |
Scott Todd | 1a7a406 | 2021-09-01 17:14:53 -0700 | [diff] [blame] | 16 | ``` |
| 17 | |
| 18 | ## Adding new benchmarks |
| 19 | |
| 20 | ### Machine learning model latency |
| 21 | |
| 22 | 1. 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 Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 28 | 2. 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 Todd | 1a7a406 | 2021-09-01 17:14:53 -0700 | [diff] [blame] | 32 | the model came from and how it was imported in case the MLIR file needs to |
| 33 | be regenerated in the future. |
| 34 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 35 | 3. Package the source model or imported MLIR file file(s) for storage (see |
Scott Todd | 1a7a406 | 2021-09-01 17:14:53 -0700 | [diff] [blame] | 36 | [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 | |
| 42 | 4. 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 | |
| 48 | 5. 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 | |
| 53 | TODO(#6161): Collect metrics for miscellaneous IREE system states |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 54 | |
| 55 | ## Developer notes |
| 56 | |
| 57 | These are ad-hoc notes added for developers to help triage errors. |
| 58 | |
| 59 | ### Repro of TFLite model errors |
| 60 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 61 | These steps help reproduce the failures in TFLite models. |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 62 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 63 | 1. Install `iree-import-tflite`. |
| 64 | ``` |
| 65 | $ python -m pip install iree-tools-tflite -f https://github.com/google/iree/releases |
| 66 | ``` |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 67 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 68 | 2. Expose and confirm the binary `iree-import-tflite` is in your path by running |
| 69 | ``` |
| 70 | $ iree-import-tflite --help |
| 71 | ``` |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 72 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 73 | 3. Download the TFLite flatbuffer for the failing benchmarks. The location can |
| 74 | be found from [this CMakeLists.txt file](./TFLite/CMakeLists.txt). |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 75 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 76 | 4. Import the TFLite model into MLIR format using: |
| 77 | ``` |
| 78 | $ iree-import-tflite <tflite-file> -o <mlir-output-file> |
| 79 | ``` |
MaheshRavishankar | e9ad2cd | 2021-12-21 14:58:04 -0800 | [diff] [blame] | 80 | |
Lei Zhang | 1a8360c | 2022-02-28 13:35:51 -0500 | [diff] [blame] | 81 | 5. 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). |