-
Notifications
You must be signed in to change notification settings - Fork 8
467 lines (424 loc) · 23.9 KB
/
run_mobile_comparative_benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# Copyright 2023 The OpenXLA Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# Mobile Comparative Benchmarks Workflow.
name: Mobile Comparative Benchmarks
on:
workflow_dispatch:
schedule:
# Scheduled to run at 09:00 UTC and 21:00 UTC.
- cron: '0 09,21 * * *'
concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
env:
GCS_DIR: gs://openxla-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts/${{ github.run_id }}/${{ github.run_attempt }}
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
runner-group: ${{ steps.configure.outputs.runner-group }}
benchmark-gcs-dir: ${{ steps.configure.outputs.benchmark-gcs-dir }}
run-timestamp: ${{ steps.configure.outputs.run-timestamp }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Configuring CI options"
id: configure
env:
RUNNER_GROUP: ${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}
run: |
# Just informative logging. There should only be two commits in the
# history here, but limiting the depth helps when copying from a local
# repo instead of using checkout, e.g. with
# https://github.com/nektos/act where there will be more.
git log --oneline --graph --max-count=3
# Workflow jobs can't access `env` in `runs-on`, so we need to make
# `runner-group` a job output variable.
echo "runner-group=${RUNNER_GROUP}" > "${GITHUB_OUTPUT}"
RUN_TIMESTAMP="$(date +'%Y-%m-%d').$(date +'%s')"
echo "run-timestamp=${RUN_TIMESTAMP}" >> "${GITHUB_OUTPUT}"
# For presubmit testing, the result artifacts are uploaded to the
# temporary workflow GCS dir. In postsubmit, the result artifacts are
# uploaded to the comparative benchmark GCS dir.
if [[ "${RUNNER_GROUP}" == "presubmit" ]]; then
BENCHMARK_GCS_DIR="${GCS_DIR}/comparative-benchmark-artifacts"
else
BENCHMARK_GCS_DIR="gs://comparative-benchmark-artifacts/${RUN_TIMESTAMP}"
fi
echo "benchmark-gcs-dir=${BENCHMARK_GCS_DIR}" >> "${GITHUB_OUTPUT}"
build_iree:
needs: setup
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- cpu
- os-family=Linux
env:
IREE_SOURCE_DIR: iree-src
IREE_INSTALL_DIR: iree-install
IREE_ANDROID_TOOLS_DIR: tools
ANDROID_PLATFORM_VERSION: 31
X86_BUILD_DIR: iree-build
ANDROID_BUILD_DIR: iree-build-android
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
outputs:
iree-install-dir: ${{ env.IREE_INSTALL_DIR }}
iree-install-dir-archive: ${{ steps.archive.outputs.iree-install-dir-archive }}
iree-install-dir-gcs-artifact: ${{ steps.upload.outputs.iree-install-dir-gcs-artifact }}
iree-android-tools-dir: ${{ env.IREE_ANDROID_TOOLS_DIR }}
iree-android-tools-dir-archive: ${{ steps.archive.outputs.iree-android-tools-dir-archive }}
iree-android-tools-dir-gcs-artifact: ${{ steps.upload.outputs.iree-android-tools-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Building IREE"
run: |
mkdir -p "${IREE_SOURCE_DIR}"
mkdir -p "${X86_BUILD_DIR}"
mkdir -p "${ANDROID_BUILD_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env IREE_SOURCE_DIR="${IREE_SOURCE_DIR}" \
--env IREE_INSTALL_DIR="${IREE_INSTALL_DIR}" \
--env ANDROID_PLATFORM_VERSION="${ANDROID_PLATFORM_VERSION}" \
"gcr.io/iree-oss/openxla-benchmark/android@sha256:cba9827bc47a6afb575efc72ed821ceda32b3132a406235d3edf6d125deef0d7" \
./experimental/iree/build_iree.sh \
"${X86_BUILD_DIR}" \
"${ANDROID_BUILD_DIR}"
- name: "Creating archives"
id: archive
env:
IREE_INSTALL_DIR_ARCHIVE: ${{ env.IREE_INSTALL_DIR }}.tgz
IREE_ANDROID_TOOLS_DIR_ARCHIVE: ${{ env.IREE_ANDROID_TOOLS_DIR }}.tgz
run: |
tar -zcvf "${IREE_INSTALL_DIR_ARCHIVE}" -C "${X86_BUILD_DIR}" "${IREE_INSTALL_DIR}"
echo "iree-install-dir-archive=${IREE_INSTALL_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
tar -zcvf "${IREE_ANDROID_TOOLS_DIR_ARCHIVE}" -C "${ANDROID_BUILD_DIR}" "${IREE_ANDROID_TOOLS_DIR}"
echo "iree-android-tools-dir-archive=${IREE_ANDROID_TOOLS_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading archives"
id: upload
env:
IREE_INSTALL_DIR_ARCHIVE: ${{ steps.archive.outputs.iree-install-dir-archive }}
IREE_INSTALL_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.iree-install-dir-archive }}
IREE_ANDROID_TOOLS_DIR_ARCHIVE: ${{ steps.archive.outputs.iree-android-tools-dir-archive }}
IREE_ANDROID_TOOLS_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.iree-android-tools-dir-archive }}
run: |
gcloud storage cp "${IREE_INSTALL_DIR_ARCHIVE}" "${IREE_INSTALL_DIR_GCS_ARTIFACT}"
echo "iree-install-dir-gcs-artifact=${IREE_INSTALL_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
gcloud storage cp "${IREE_ANDROID_TOOLS_DIR_ARCHIVE}" "${IREE_ANDROID_TOOLS_DIR_GCS_ARTIFACT}"
echo "iree-android-tools-dir-gcs-artifact=${IREE_ANDROID_TOOLS_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
build_tflite:
needs: setup
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- cpu
- os-family=Linux
env:
TF_SOURCE_DIR: tf-src
X86_BUILD_DIR: tf-build
ANDROID_BUILD_DIR: tf-build-android
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
outputs:
tflite-build-dir: ${{ env.X86_BUILD_DIR }}
tflite-build-dir-archive: ${{ steps.archive.outputs.tflite-build-dir-archive }}
tflite-build-dir-gcs-artifact: ${{ steps.upload.outputs.tflite-build-dir-gcs-artifact }}
tflite-android-build-dir: ${{ env.ANDROID_BUILD_DIR }}
tflite-android-build-dir-archive: ${{ steps.archive.outputs.tflite-android-build-dir-archive }}
tflite-android-build-dir-gcs-artifact: ${{ steps.upload.outputs.tflite-android-build-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Building TFLite"
run: |
mkdir -p "${TF_SOURCE_DIR}"
mkdir -p "${X86_BUILD_DIR}"
mkdir -p "${ANDROID_BUILD_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env OOBI_TEMP_DIR="${TF_SOURCE_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/tflite-android@sha256:a9e6c363edb8a10d460dd2eebce22e59a005b5125104eb111ed6586470591cc2" \
./experimental/tflite/build_tflite.sh \
"${X86_BUILD_DIR}" \
"${ANDROID_BUILD_DIR}"
- name: "Creating archives"
id: archive
env:
TFLITE_BUILD_DIR_ARCHIVE: ${{ env.X86_BUILD_DIR }}.tgz
TFLITE_ANDROID_BUILD_DIR_ARCHIVE: ${{ env.ANDROID_BUILD_DIR }}.tgz
run: |
tar -zcvf "${TFLITE_BUILD_DIR_ARCHIVE}" "${X86_BUILD_DIR}"
echo "tflite-build-dir-archive=${TFLITE_BUILD_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
tar -zcvf "${TFLITE_ANDROID_BUILD_DIR_ARCHIVE}" "${ANDROID_BUILD_DIR}"
echo "tflite-android-build-dir-archive=${TFLITE_ANDROID_BUILD_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading archives"
id: upload
env:
TFLITE_BUILD_DIR_ARCHIVE: ${{ steps.archive.outputs.tflite-build-dir-archive }}
TFLITE_BUILD_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.tflite-build-dir-archive }}
TFLITE_ANDROID_BUILD_DIR_ARCHIVE: ${{ steps.archive.outputs.tflite-android-build-dir-archive }}
TFLITE_ANDROID_BUILD_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.tflite-android-build-dir-archive }}
run: |
gcloud storage cp "${TFLITE_BUILD_DIR_ARCHIVE}" "${TFLITE_BUILD_DIR_GCS_ARTIFACT}"
echo "tflite-build-dir-gcs-artifact=${TFLITE_BUILD_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
gcloud storage cp "${TFLITE_ANDROID_BUILD_DIR_ARCHIVE}" "${TFLITE_ANDROID_BUILD_DIR_GCS_ARTIFACT}"
echo "tflite-android-build-dir-gcs-artifact=${TFLITE_ANDROID_BUILD_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
# We compile and benchmark on the same machine because it takes too much time to compress and upload compiled artifacts.
compile_and_benchmark_on_c2-standard-60:
needs: [setup, build_iree, build_tflite]
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=c2-standard-60
env:
BENCHMARK_ARTIFACTS_DIR: benchmark-artifacts-dir
TARGET_DEVICE: c2-standard-60
IREE_INSTALL_DIR: ${{ needs.build_iree.outputs.iree-install-dir }}
IREE_INSTALL_DIR_ARCHIVE: ${{ needs.build_iree.outputs.iree-install-dir-archive }}
IREE_INSTALL_DIR_GCS_ARTIFACT: ${{ needs.build_iree.outputs.iree-install-dir-gcs-artifact }}
TFLITE_BUILD_DIR: ${{ needs.build_tflite.outputs.tflite-build-dir }}
TFLITE_BUILD_DIR_ARCHIVE: ${{ needs.build_tflite.outputs.tflite-build-dir-archive }}
TFLITE_BUILD_DIR_GCS_ARTIFACT: ${{ needs.build_tflite.outputs.tflite-build-dir-gcs-artifact }}
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Downloading and unpacking IREE tools"
run: |
gcloud storage cp "${IREE_INSTALL_DIR_GCS_ARTIFACT}" "${IREE_INSTALL_DIR_ARCHIVE}"
tar -xvf "${IREE_INSTALL_DIR_ARCHIVE}"
- name: "Compiling workloads"
id: compile
env:
IREE_COMPILE_PATH: ${{ env.IREE_INSTALL_DIR }}/bin/iree-compile
IREE_TEMP_DIR: iree-temp
run: |
mkdir "${BENCHMARK_ARTIFACTS_DIR}"
mkdir "${IREE_TEMP_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env IREE_COMPILE_PATH="${IREE_COMPILE_PATH}" \
--env OOBI_TEMP_DIR="${IREE_TEMP_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.11@sha256:b9b98da7bcc5e431800ff798a6dcc394b1838a9ed3d695f5cd0dac3510fc8c8d" \
./experimental/iree/compile_workloads.sh \
"${TARGET_DEVICE}" \
"${BENCHMARK_ARTIFACTS_DIR}"
- name: "Benchmarking IREE:CPU"
id: benchmark-iree
env:
IREE_RESULTS_FILE: iree-${{ env.TARGET_DEVICE }}.json
RESULTS_GCS_DIR: ${{ env.BENCHMARK_GCS_DIR }}/${{ env.TARGET_DEVICE }}-results
run: |
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env OOBI_IREE_BENCHMARK_MODULE_PATH="${IREE_INSTALL_DIR}/bin/iree-benchmark-module" \
--env OOBI_IREE_RUN_MODULE_PATH="${IREE_INSTALL_DIR}/bin/iree-run-module" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.11@sha256:b9b98da7bcc5e431800ff798a6dcc394b1838a9ed3d695f5cd0dac3510fc8c8d" \
./experimental/iree/benchmark_iree_x86.sh \
"${TARGET_DEVICE}" \
"${BENCHMARK_ARTIFACTS_DIR}" \
"${IREE_RESULTS_FILE}"
gcloud storage cp "${IREE_RESULTS_FILE}" "${RESULTS_GCS_DIR}/"
echo "iree-results-file=${IREE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
echo "iree-results-gcs-path=${RESULTS_GCS_DIR}/${IREE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
- name: "Downloading and unpacking TFLite tools"
run: |
gcloud storage cp "${TFLITE_BUILD_DIR_GCS_ARTIFACT}" "${TFLITE_BUILD_DIR_ARCHIVE}"
tar -xvf "${TFLITE_BUILD_DIR_ARCHIVE}"
- name: "Benchmarking TFLite:CPU"
id: benchmark-tflite
env:
TFLITE_TEMP_DIR: tflite-temp
TFLITE_RESULTS_FILE: tflite-${{ env.TARGET_DEVICE }}.json
RESULTS_GCS_DIR: ${{ env.BENCHMARK_GCS_DIR }}/${{ env.TARGET_DEVICE }}-results
run: |
mkdir "${TFLITE_TEMP_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env OOBI_TEMP_DIR="${TFLITE_TEMP_DIR}" \
--env TFLITE_BENCHMARK_BINARY="${TFLITE_BUILD_DIR}/benchmark_model" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.11@sha256:b9b98da7bcc5e431800ff798a6dcc394b1838a9ed3d695f5cd0dac3510fc8c8d" \
./experimental/tflite/benchmark_tflite_x86.sh \
"${TARGET_DEVICE}" \
"${TFLITE_RESULTS_FILE}"
gcloud storage cp "${TFLITE_RESULTS_FILE}" "${RESULTS_GCS_DIR}/"
echo "tflite-results-file=${TFLITE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
echo "tflite-results-gcs-path=${RESULTS_GCS_DIR}/${TFLITE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
- name: "Generating report"
env:
IREE_RESULTS_FILE: ${{ steps.benchmark-iree.outputs.iree-results-file }}
IREE_RESULTS_GCS_PATH: ${{ steps.benchmark-iree.outputs.iree-results-gcs-path }}
TFLITE_RESULTS_FILE: ${{ steps.benchmark-tflite.outputs.tflite-results-file }}
TFLITE_RESULTS_GCS_PATH: ${{ steps.benchmark-tflite.outputs.tflite-results-gcs-path }}
SUMMARY_HTML: server_summary.html
SUMMARY_HTML_GCS_PATH: "gs://tflite-benchmark-artifacts/server"
RUN_TIMESTAMP: ${{ needs.setup.outputs.run-timestamp }}
run: |
gcloud storage cp "${IREE_RESULTS_GCS_PATH}" "${IREE_RESULTS_FILE}"
gcloud storage cp "${TFLITE_RESULTS_GCS_PATH}" "${TFLITE_RESULTS_FILE}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base-python3.11@sha256:b9b98da7bcc5e431800ff798a6dcc394b1838a9ed3d695f5cd0dac3510fc8c8d" \
./experimental/utils/generate_iree_vs_tflite_report.sh \
"${IREE_RESULTS_FILE}" \
"${TFLITE_RESULTS_FILE}" \
"${SUMMARY_HTML}"
gcloud storage cp "${SUMMARY_HTML}" "${BENCHMARK_GCS_DIR}/${SUMMARY_HTML}"
gcloud storage cp "${IREE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/latest/iree.json"
gcloud storage cp "${TFLITE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/latest/tflite.json"
gcloud storage cp "${SUMMARY_HTML}" "${SUMMARY_HTML_GCS_PATH}/latest/${SUMMARY_HTML}"
gcloud storage cp "${IREE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/iree.json"
gcloud storage cp "${TFLITE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/tflite.json"
gcloud storage cp "${SUMMARY_HTML}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/${SUMMARY_HTML}"
compile_models_for_android:
needs: [setup, build_iree]
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- cpu
- os-family=Linux
env:
BENCHMARK_ARTIFACTS_DIR: android-benchmark-artifacts-dir
TARGET_DEVICE: pixel-8-pro
IREE_INSTALL_DIR: ${{ needs.build_iree.outputs.iree-install-dir }}
IREE_INSTALL_DIR_ARCHIVE: ${{ needs.build_iree.outputs.iree-install-dir-archive }}
IREE_INSTALL_DIR_GCS_ARTIFACT: ${{ needs.build_iree.outputs.iree-install-dir-gcs-artifact }}
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
outputs:
benchmark-artifacts-dir: ${{ env.BENCHMARK_ARTIFACTS_DIR }}
benchmark-artifacts-dir-archive: ${{ steps.archive.outputs.benchmark-artifacts-dir-archive }}
benchmark-artifacts-dir-gcs-artifact: ${{ steps.upload.outputs.benchmark-artifacts-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Downloading and unpacking IREE tools"
run: |
gcloud storage cp "${IREE_INSTALL_DIR_GCS_ARTIFACT}" "${IREE_INSTALL_DIR_ARCHIVE}"
tar -xvf "${IREE_INSTALL_DIR_ARCHIVE}"
- name: "Compiling workloads"
id: compile
env:
IREE_COMPILE_PATH: ${{ env.IREE_INSTALL_DIR }}/bin/iree-compile
OOBI_TEMP_DIR: temp
run: |
mkdir "${BENCHMARK_ARTIFACTS_DIR}"
mkdir "${OOBI_TEMP_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env IREE_COMPILE_PATH="${IREE_COMPILE_PATH}" \
--env OOBI_TEMP_DIR="${OOBI_TEMP_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/android@sha256:cba9827bc47a6afb575efc72ed821ceda32b3132a406235d3edf6d125deef0d7" \
./experimental/iree/compile_workloads.sh \
"${TARGET_DEVICE}" \
"${BENCHMARK_ARTIFACTS_DIR}"
- name: "Creating archives"
id: archive
env:
BENCHMARK_ARTIFACTS_DIR_ARCHIVE: ${{ env.BENCHMARK_ARTIFACTS_DIR }}.tgz
run: |
tar -cvf "${BENCHMARK_ARTIFACTS_DIR_ARCHIVE}" "${BENCHMARK_ARTIFACTS_DIR}"
echo "benchmark-artifacts-dir-archive=${BENCHMARK_ARTIFACTS_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading archives"
id: upload
env:
BENCHMARK_ARTIFACTS_DIR_ARCHIVE: ${{ steps.archive.outputs.benchmark-artifacts-dir-archive }}
BENCHMARK_ARTIFACTS_DIR_GCS_ARTIFACT: ${{ env.BENCHMARK_GCS_DIR }}/${{ steps.archive.outputs.benchmark-artifacts-dir-archive }}
run: |
gcloud storage cp "${BENCHMARK_ARTIFACTS_DIR_ARCHIVE}" "${BENCHMARK_ARTIFACTS_DIR_GCS_ARTIFACT}"
echo "benchmark-artifacts-dir-gcs-artifact=${BENCHMARK_ARTIFACTS_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
benchmark_on_pixel-8-pro:
needs: [setup, build_iree, compile_models_for_android, build_tflite]
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=pixel-8-pro
env:
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
RESULTS_DIR: results-dir
TARGET_DEVICE: pixel-8-pro
IREE_ANDROID_TOOLS_DIR: ${{ needs.build_iree.outputs.iree-android-tools-dir }}
IREE_ANDROID_TOOLS_DIR_ARCHIVE: ${{ needs.build_iree.outputs.iree-android-tools-dir-archive }}
IREE_ANDROID_TOOLS_DIR_GCS_ARTIFACT: ${{ needs.build_iree.outputs.iree-android-tools-dir-gcs-artifact }}
IREE_ARTIFACTS_DIR: ${{ needs.compile_models_for_android.outputs.benchmark-artifacts-dir }}
IREE_ARTIFACTS_DIR_ARCHIVE: ${{ needs.compile_models_for_android.outputs.benchmark-artifacts-dir-archive }}
IREE_ARTIFACTS_DIR_GCS_ARTIFACT: ${{ needs.compile_models_for_android.outputs.benchmark-artifacts-dir-gcs-artifact }}
TFLITE_ANDROID_BUILD_DIR: ${{ needs.build_tflite.outputs.tflite-android-build-dir }}
TFLITE_ANDROID_BUILD_DIR_ARCHIVE: ${{ needs.build_tflite.outputs.tflite-android-build-dir-archive }}
TFLITE_ANDROID_BUILD_DIR_GCS_ARTIFACT: ${{ needs.build_tflite.outputs.tflite-android-build-dir-gcs-artifact }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Setup"
id: setup
run: |
echo "results-gcs-dir=${BENCHMARK_GCS_DIR}/${TARGET_DEVICE}-results" >> "${GITHUB_OUTPUT}"
mkdir "${RESULTS_DIR}"
- name: "Downloading and unpacking tools"
run: |
gcloud storage cp "${IREE_ANDROID_TOOLS_DIR_GCS_ARTIFACT}" "${IREE_ANDROID_TOOLS_DIR_ARCHIVE}"
tar -xvf "${IREE_ANDROID_TOOLS_DIR_ARCHIVE}"
- name: "Benchmarking IREE on Android"
id: benchmark-iree
env:
IREE_RESULTS_FILE: iree-${{ env.TARGET_DEVICE }}.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${IREE_RESULTS_FILE}"
# We use the `https` path instead of `gs` since artifact streaming only works with `https`.
IREE_ARTIFACTS_DIR_HTTPS_ARTIFACT=$(echo "${IREE_ARTIFACTS_DIR_GCS_ARTIFACT}" | sed -E 's/gs:\/\/(.*)/https:\/\/storage.googleapis.com\/\1/')
OOBI_IREE_RUN_MODULE_PATH="${IREE_ANDROID_TOOLS_DIR}/iree-run-module" \
OOBI_IREE_BENCHMARK_MODULE_PATH="${IREE_ANDROID_TOOLS_DIR}/iree-benchmark-module" \
./experimental/iree/benchmark_iree_android.sh \
"${TARGET_DEVICE}" \
"${IREE_ARTIFACTS_DIR_HTTPS_ARTIFACT}" \
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
echo "iree-results-file=${IREE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
echo "iree-results-gcs-path=${RESULTS_GCS_DIR}/${IREE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
- name: "Downloading and unpacking TFLite tools"
run: |
gcloud storage cp "${TFLITE_ANDROID_BUILD_DIR_GCS_ARTIFACT}" "${TFLITE_ANDROID_BUILD_DIR_ARCHIVE}"
tar -xvf "${TFLITE_ANDROID_BUILD_DIR_ARCHIVE}"
- name: "Benchmarking TFLite on Android"
id: benchmark-tflite
env:
TFLITE_RESULTS_FILE: tflite-${{ env.TARGET_DEVICE }}.json
RESULTS_GCS_DIR: ${{ steps.setup.outputs.results-gcs-dir }}
run: |
RESULTS_PATH="${RESULTS_DIR}/${TFLITE_RESULTS_FILE}"
TFLITE_BENCHMARK_BINARY="${TFLITE_ANDROID_BUILD_DIR}/benchmark_model" \
./experimental/tflite/benchmark_tflite_android.sh \
"${TARGET_DEVICE}" \
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
echo "tflite-results-file=${TFLITE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
echo "tflite-results-gcs-path=${RESULTS_GCS_DIR}/${TFLITE_RESULTS_FILE}" >> "${GITHUB_OUTPUT}"
- name: "Generating report"
env:
IREE_RESULTS_FILE: ${{ steps.benchmark-iree.outputs.iree-results-file }}
IREE_RESULTS_GCS_PATH: ${{ steps.benchmark-iree.outputs.iree-results-gcs-path }}
TFLITE_RESULTS_FILE: ${{ steps.benchmark-tflite.outputs.tflite-results-file }}
TFLITE_RESULTS_GCS_PATH: ${{ steps.benchmark-tflite.outputs.tflite-results-gcs-path }}
SUMMARY_HTML: mobile_summary.html
SUMMARY_HTML_GCS_PATH: "gs://tflite-benchmark-artifacts/mobile"
BENCHMARK_GCS_DIR: ${{ needs.setup.outputs.benchmark-gcs-dir }}
RUN_TIMESTAMP: ${{ needs.setup.outputs.run-timestamp }}
run: |
gcloud storage cp "${IREE_RESULTS_GCS_PATH}" "${IREE_RESULTS_FILE}"
gcloud storage cp "${TFLITE_RESULTS_GCS_PATH}" "${TFLITE_RESULTS_FILE}"
./experimental/utils/generate_iree_vs_tflite_report.sh \
"${IREE_RESULTS_FILE}" \
"${TFLITE_RESULTS_FILE}" \
"${SUMMARY_HTML}"
gcloud storage cp "${SUMMARY_HTML}" "${BENCHMARK_GCS_DIR}/${SUMMARY_HTML}"
gcloud storage cp "${IREE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/latest/iree.json"
gcloud storage cp "${TFLITE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/latest/tflite.json"
gcloud storage cp "${SUMMARY_HTML}" "${SUMMARY_HTML_GCS_PATH}/latest/${SUMMARY_HTML}"
gcloud storage cp "${IREE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/iree.json"
gcloud storage cp "${TFLITE_RESULTS_FILE}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/tflite.json"
gcloud storage cp "${SUMMARY_HTML}" "${SUMMARY_HTML_GCS_PATH}/${RUN_TIMESTAMP}/${SUMMARY_HTML}"