-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jerry Wu
committed
Jul 6, 2023
1 parent
cbd3b0f
commit 3abe70a
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# | ||
# 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 | ||
|
||
set -xeuo pipefail | ||
|
||
VENV_DIR="${OOBI_VENV_DIR:-pt-benchmarks.venv}" | ||
PYTHON="${PYTHON:-/usr/bin/python3}" | ||
TARGET_DEVICE="${1:-${OOBI_TARGET_DEVICE}}" | ||
OUTPUT_PATH="${2:-${OOBI_OUTPUT}}" | ||
|
||
TD="$(cd $(dirname $0) && pwd)" | ||
|
||
VENV_DIR="${VENV_DIR}" PYTHON="${PYTHON}" source "${TD}/setup_venv.sh" | ||
|
||
declare -a GPU_BENCHMARK_NAMES=( | ||
"models/BERT_LARGE_FP32_PT_.+/inputs/.+/expected_outputs/.+/target_devices/a2-highgpu-1g" | ||
"models/BERT_LARGE_FP16_PT_.+/inputs/.+/expected_outputs/.+/target_devices/a2-highgpu-1g" | ||
) | ||
|
||
declare -a CPU_BENCHMARK_NAMES=( | ||
"models/BERT_LARGE_FP32_PT_.+_BATCH1/inputs/.+/expected_outputs/.+/target_devices/c2-standard-16" | ||
"models/BERT_LARGE_FP32_PT_.+_BATCH32/inputs/.+/expected_outputs/.+/target_devices/c2-standard-16" | ||
"models/BERT_LARGE_FP32_PT_.+_BATCH64/inputs/.+/expected_outputs/.+/target_devices/c2-standard-16" | ||
) | ||
|
||
if [ "${TARGET_DEVICE}" = "a2-highgpu-1g" ]; then | ||
BENCHMARK_NAMES=("${GPU_BENCHMARK_NAMES[@]}") | ||
ITERATIONS=50 | ||
elif [ "${TARGET_DEVICE}" = "c2-standard-16" ]; then | ||
BENCHMARK_NAMES=("${CPU_BENCHMARK_NAMES[@]}") | ||
ITERATIONS=20 | ||
else | ||
echo "Unsupported target device ${TARGET_DEVICE}." | ||
exit 1 | ||
fi | ||
|
||
"${TD}/../scripts/create_results_json.sh" "${OUTPUT_PATH}" | ||
|
||
for benchmark_name in "${BENCHMARK_NAMES[@]}"; do | ||
"${TD}/run_benchmarks.py" \ | ||
--benchmark_name="${benchmark_name}" \ | ||
--output="${OUTPUT_PATH}" \ | ||
--iterations="${ITERATIONS}" \ | ||
--verbose | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
# | ||
# 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 | ||
# | ||
# Environment variables: | ||
# VENV_DIR=tf-benchmarks.venv | ||
# PYTHON=/usr/bin/python3.10 | ||
|
||
set -xeuo pipefail | ||
|
||
TD="$(cd $(dirname $0) && pwd)" | ||
VENV_DIR=${VENV_DIR:-pt-benchmarks.venv} | ||
PYTHON="${PYTHON:-"$(which python3)"}" | ||
|
||
"${PYTHON}" -m venv "${VENV_DIR}" || echo "Could not create venv." | ||
source "${VENV_DIR}/bin/activate" || echo "Could not activate venv" | ||
|
||
# Upgrade pip and install requirements. 'python' is used here in order to | ||
# reference to the python executable from the venv. | ||
python -m pip install --upgrade pip || die "Could not upgrade pip" | ||
python -m pip install -r "${TD}/requirements.txt" | ||
|
||
echo "Activate venv with:" | ||
echo " source ${VENV_DIR}/bin/activate" |