2022-10-26 22:19:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Helper script to run the bench tool on all models and print the results in share-able format
|
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
printf "Usage: ./bench.sh [n_threads] [encoder-only]\n"
|
2022-10-26 22:19:58 +02:00
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
n_threads=4
|
|
|
|
else
|
|
|
|
n_threads=$1
|
|
|
|
fi
|
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
encoder_only=0
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
encoder_only=0
|
|
|
|
else
|
|
|
|
encoder_only=$2
|
|
|
|
fi
|
2022-10-26 22:19:58 +02:00
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
models=( \
|
|
|
|
"tiny" "tiny-q5_0" "tiny-q5_1" "tiny-q8_0" \
|
|
|
|
"base" "base-q5_0" "base-q5_1" "base-q8_0" \
|
|
|
|
"small" "small-q5_0" "small-q5_1" "small-q8_0" \
|
|
|
|
"medium" "medium-q5_0" "medium-q5_1" "medium-q8_0" \
|
|
|
|
"large" "large-q5_0" "large-q5_1" "large-q8_0" \
|
|
|
|
)
|
2023-01-18 19:31:46 +01:00
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
if [ "$encoder_only" -eq 0 ]; then
|
|
|
|
printf "\n"
|
|
|
|
printf "Running memcpy benchmark\n"
|
|
|
|
printf "\n"
|
2023-01-18 19:31:46 +01:00
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
./bench -w 1 -t $n_threads 2>&1
|
2023-01-18 19:31:46 +01:00
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
printf "\n"
|
|
|
|
printf "Running ggml_mul_mat benchmark with $n_threads threads\n"
|
|
|
|
printf "\n"
|
2023-01-18 19:31:46 +01:00
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
./bench -w 2 -t $n_threads 2>&1
|
|
|
|
|
|
|
|
printf "\n"
|
|
|
|
printf "Running benchmark for all models\n"
|
|
|
|
printf "This can take a while!\n"
|
|
|
|
printf "\n"
|
|
|
|
fi
|
2022-10-26 22:19:58 +02:00
|
|
|
|
2022-12-11 10:56:13 +01:00
|
|
|
printf "| CPU | OS | Config | Model | Th | Load | Enc. | Commit |\n"
|
|
|
|
printf "| --- | -- | ------ | ----- | -- | ---- | ---- | ------ |\n"
|
2022-10-26 22:19:58 +02:00
|
|
|
|
|
|
|
for model in "${models[@]}"; do
|
|
|
|
# run once to heat-up the cache
|
|
|
|
./bench -m ./models/ggml-$model.bin -t $n_threads 2>/dev/null 1>/dev/null
|
|
|
|
|
|
|
|
# actual run
|
|
|
|
# store stderr output in a variable in order to parse it later
|
|
|
|
output=$(./bench -m ./models/ggml-$model.bin -t $n_threads 2>&1)
|
2023-05-01 13:44:39 +02:00
|
|
|
ret=$?
|
2022-10-26 22:19:58 +02:00
|
|
|
|
|
|
|
# parse the output:
|
|
|
|
load_time=$(echo "$output" | grep "load time" | awk '{print $5}')
|
|
|
|
encode_time=$(echo "$output" | grep "encode time" | awk '{print $5}')
|
|
|
|
system_info=$(echo "$output" | grep "system_info")
|
|
|
|
n_threads=$(echo "$output" | grep "system_info" | awk '{print $4}')
|
|
|
|
|
2022-12-11 10:56:13 +01:00
|
|
|
# floor to milliseconds
|
|
|
|
load_time=${load_time%.*}
|
|
|
|
encode_time=${encode_time%.*}
|
|
|
|
|
2022-10-26 22:19:58 +02:00
|
|
|
config=""
|
|
|
|
|
|
|
|
if [[ $system_info == *"AVX2 = 1"* ]]; then
|
|
|
|
config="$config AVX2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $system_info == *"NEON = 1"* ]]; then
|
|
|
|
config="$config NEON"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $system_info == *"BLAS = 1"* ]]; then
|
|
|
|
config="$config BLAS"
|
|
|
|
fi
|
|
|
|
|
2023-04-15 12:21:27 +02:00
|
|
|
if [[ $system_info == *"COREML = 1"* ]]; then
|
|
|
|
config="$config COREML"
|
|
|
|
fi
|
|
|
|
|
2022-12-06 17:47:48 +01:00
|
|
|
commit=$(git rev-parse --short HEAD)
|
|
|
|
|
2023-05-01 13:44:39 +02:00
|
|
|
if [ $ret -eq 0 ]; then
|
|
|
|
printf "| <todo> | <todo> | $config | $model | $n_threads | $load_time | $encode_time | $commit |\n"
|
|
|
|
fi
|
2022-10-26 22:19:58 +02:00
|
|
|
done
|