From a8f0e40e30a36aa6bec615213208f6e93254cbbf Mon Sep 17 00:00:00 2001 From: Aizaixyq <96584640+Aizaixyq@users.noreply.github.com> Date: Sun, 19 Mar 2023 17:07:19 +0800 Subject: [PATCH] Fix scripts to support cross-platform execution --- quantize.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/quantize.sh b/quantize.sh index 6194649b3..c9ccf4bd4 100755 --- a/quantize.sh +++ b/quantize.sh @@ -7,8 +7,22 @@ if ! [[ "$1" =~ ^[0-9]{1,2}B$ ]]; then exit 1 fi +# Determine the binary file extension based on the platform +case "$(uname -s)" in + Linux*) + if grep -qE "(Microsoft|WSL)" /proc/version &> /dev/null ; then + ext=".exe" # WSL environment + else + ext="" + fi + ;; + Darwin*) ext="";; + CYGWIN*|MINGW32*|MSYS*|MINGW*) ext=".exe";; + *) echo "Unknown platform"; exit 1;; +esac + for i in `ls models/$1/ggml-model-f16.bin*`; do - ./quantize "$i" "${i/f16/q4_0}" 2 + ./quantize${ext} "$i" "${i/f16/q4_0}" 2 if [[ "$2" == "--remove-f16" ]]; then rm "$i" fi