-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlc0-nets
More file actions
executable file
·75 lines (68 loc) · 1.61 KB
/
lc0-nets
File metadata and controls
executable file
·75 lines (68 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
file=lc0-nets.json
if [ -z "$1" ]; then
echo "Usage: $0 command"
echo
echo "Commands:"
echo "- urls - print the urls"
echo "- names - print names of the nets"
echo "- froms - print names of the authors"
echo "- download - download all urls"
echo "- genscript - generate the lc0 runner scripts"
exit 0
fi
if [ "$1" = 'urls' ]; then
jq -r '.[].url' < "$file"
fi
if [ "$1" = 'names' ]; then
jq -r '.[].name' < "$file"
fi
if [ "$1" = 'froms' ]; then
jq -r '.[].from' < "$file" | sort | uniq -c
fi
if [ "$1" = 'download' ]; then
i=0
net=
while :; do
net=$(jq -r ".[$i]" < "$file")
i=$(($i+1))
if [[ $net =~ null ]]; then
break
fi
from=`echo "$net" | jq -r '.from'`
if [ -n "$2" -a "$2" != "$from" ]; then
continue
fi
url=`echo "$net" | jq -r '.url'`
fname=`basename "$url"`
wget -c "$url" -O "$from-$fname"
done
fi
if [ "$1" = 'genscript' -o "$1" = 'genscripts' ]; then
i=0
net=
while :; do
net=$(jq -r ".[$i]" < "$file")
i=$(($i+1))
if [[ $net =~ null ]]; then
break
fi
from=`echo "$net" | jq -r '.from'`
url=`echo "$net" | jq -r '.url'`
name=`echo "$net" | jq -r '.name'`
desc=`echo "$net" | jq -r '.desc'`
fname=`basename "$url"`
netname="$from-$fname"
out="lc0-$from-$name"
path="`pwd`"
echo "#!/bin/sh" > "$out"
chmod 755 "$out"
echo "# WARNING: this file is autogenerated and will be overwritten" >> "$out"
echo >> "$out"
echo "# From: $from ($url)" >> "$out"
echo -e "$desc" | sed -e 's/^/# /' >> "$out"
echo >> "$out"
echo "lc0 \"--weights=$path/$netname\"" >> "$out"
echo Generated "$out"
done
fi