echodict/llama.cpp
version https://git-lfs.github.com/spec/v1 oid sha256:cfc44b7ba25614df70e6b65e3341cae0310163bd32fd31a6b928a542df433faf size 30786
0773
1#!/usr/bin/env bash2 3if [ $# -lt 2 ]; then4 echo "usage: ./scripts/compare-commits.sh <commit1> <commit2> [tool] [additional arguments]"5 echo " tool: 'llama-bench' (default) or 'test-backend-ops'"6 echo " additional arguments: passed to the selected tool"7 exit 18fi9 10set -e11set -x12 13# Parse arguments14commit1=$115commit2=$216tool=${3:-llama-bench}17additional_args="${@:4}"18 19# Validate tool argument20if [ "$tool" != "llama-bench" ] && [ "$tool" != "test-backend-ops" ]; then21 echo "Error: tool must be 'llama-bench' or 'test-backend-ops'"22 exit 123fi24 25# verify at the start that the compare script has all the necessary dependencies installed26./scripts/compare-llama-bench.py --check27 28if ! command -v sqlite3 >/dev/null 2>&1; then29 echo "Error: sqlite3 is not installed or not in PATH"30 echo "Please install sqlite3 to use this script"31 exit 132fi33 34if [ "$tool" = "llama-bench" ]; then35 db_file="llama-bench.sqlite"36 target="llama-bench"37 run_args="-o sql -oe md $additional_args"38else # test-backend-ops39 db_file="test-backend-ops.sqlite"40 target="test-backend-ops"41 run_args="perf --output sql $additional_args"42fi43 44rm -f "$db_file" > /dev/null45 46# to test a backend, call the script with the corresponding environment variable (e.g. GGML_CUDA=1 ./scripts/compare-commits.sh ...)47if [ -n "$GGML_CUDA" ]; then48 CMAKE_OPTS="${CMAKE_OPTS} -DGGML_CUDA=ON"49fi50 51dir="build-bench"52 53function run {54 rm -fr ${dir} > /dev/null55 cmake -B ${dir} -S . ${CMAKE_OPTS} > /dev/null56 cmake --build ${dir} -t $target -j $(nproc) > /dev/null57 ${dir}/bin/$target $run_args | sqlite3 "$db_file"58}59 60git checkout $commit1 > /dev/null61run62 63git checkout $commit2 > /dev/null64run65 66./scripts/compare-llama-bench.py -b $commit1 -c $commit2 --tool $tool -i "$db_file"67 