Skip to content

Commit 15aa3da

Browse files
extra : update 'quantize-all.sh' to quantize all downloaded models (ggml-org#1054)
Script will now do what it says: quantize everything except testing models in the 'models' directory.
1 parent b73f9d4 commit 15aa3da

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

extra/quantize-all.sh

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,48 @@ fi
1010
qtype0="q5_0"
1111
qtype1="q5_1"
1212
upload="$1"
13+
declare -a filedex
1314

1415
cd `dirname $0`
1516
cd ../
1617

17-
./quantize ./models/ggml-tiny.en.bin ./models/ggml-tiny.en-${qtype1}.bin ${qtype1}
18-
./quantize ./models/ggml-tiny.bin ./models/ggml-tiny-${qtype1}.bin ${qtype1}
18+
# Let's loop across all the objects in the 'models' dir:
19+
for i in ./models/*; do
20+
# Check to see if it's a file or directory
21+
if [ -d "$i" ]; then
22+
# It's a directory! We should make sure it's not empty first:
23+
if [ "$(ls -A $i)" ]; then
24+
# Passed! Let's go searching for bin files (shouldn't need to go more than a layer deep here)
25+
for f in "$i"/*.bin; do
26+
# [Neuron Activation]
27+
newfile=`echo "${f##*/}" | cut -d _ -f 1`;
28+
if [ "$newfile" != "q5" ]; then
29+
./quantize "${f}" "${i:-4}/${i:9:${#i}-4}-${qtype1}.bin" ${qtype1};
30+
./quantize "${f}" "${i:-4}/${i:9:${#i}-4}-${qtype0}.bin" ${qtype0};
31+
filedex+=( "${i:-4}/${i:9:${#i}-4}-${qtype1}.bin" "${i:-4}/${i:9:${#i}-4}-${qtype0}.bin" )
32+
fi
33+
done
34+
fi
35+
else
36+
# It's a file! Let's make sure it's the right type:
37+
if [ "${i##*.}" == "bin" ]; then
38+
# And we probably want to skip the testing files
39+
if [ "${i:9:8}" != "for-test" ]; then
40+
# [Neuron Activation]
41+
./quantize "${i}" "${i:-4}-${qtype1}.bin" ${qtype1};
42+
./quantize "${i}" "${i:-4}-${qtype0}.bin" ${qtype0};
43+
filedex+=( "${i:-4}-${qtype1}.bin" "${i:-4}-${qtype0}.bin" )
44+
fi
45+
fi
46+
fi
47+
done
1948

20-
./quantize ./models/ggml-base.en.bin ./models/ggml-base.en-${qtype1}.bin ${qtype1}
21-
./quantize ./models/ggml-base.bin ./models/ggml-base-${qtype1}.bin ${qtype1}
2249

23-
./quantize ./models/ggml-small.en.bin ./models/ggml-small.en-${qtype1}.bin ${qtype1}
24-
./quantize ./models/ggml-small.bin ./models/ggml-small-${qtype1}.bin ${qtype1}
25-
26-
./quantize ./models/ggml-medium.en.bin ./models/ggml-medium.en-${qtype0}.bin ${qtype0}
27-
./quantize ./models/ggml-medium.bin ./models/ggml-medium-${qtype0}.bin ${qtype0}
28-
29-
./quantize ./models/ggml-large.bin ./models/ggml-large-${qtype0}.bin ${qtype0}
3050

3151
if [ "$upload" == "1" ]; then
32-
scp ./models/ggml-tiny.en-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-tiny.en-${qtype1}.bin
33-
scp ./models/ggml-tiny-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-tiny-${qtype1}.bin
34-
35-
scp ./models/ggml-base.en-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-base.en-${qtype1}.bin
36-
scp ./models/ggml-base-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-base-${qtype1}.bin
37-
38-
scp ./models/ggml-small.en-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-small.en-${qtype1}.bin
39-
scp ./models/ggml-small-${qtype1}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-small-${qtype1}.bin
40-
41-
scp ./models/ggml-medium.en-${qtype0}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-medium.en-${qtype0}.bin
42-
scp ./models/ggml-medium-${qtype0}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-medium-${qtype0}.bin
43-
44-
scp ./models/ggml-large-${qtype0}.bin root@linode0:/mnt/Data/ggml/ggml-model-whisper-large-${qtype0}.bin
52+
for i in ${!filedex[@]}; do
53+
if [ "${filedex[$i]:9:8}" != "for-test" ]; then
54+
scp ${filedex[$i]} root@linode0:/mnt/Data/ggml/ggml-model-${filedex[$i]:9}
55+
fi
56+
done
4557
fi

0 commit comments

Comments
 (0)