-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfuzz.sh
executable file
·67 lines (57 loc) · 2.25 KB
/
fuzz.sh
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
#!/bin/bash
set -x
cd "$(dirname "$0")"
echo "NSIZE: $1";
echo "METHOD: $2";
echo "MODEL: $3";
echo "BACKEND: $4";
echo "TIME: $5";
NSIZE="$1"
METHOD="$2"
MODEL="$3"
BACKEND="$4"
TIME="$5"
# assert non-empty above
if [ -z "$NSIZE" ] || [ -z "$METHOD" ] || [ -z "$MODEL" ] || [ -z "$TIME" ]; then
echo "Usage: $0 NSIZE METHOD MODEL BACKEND TIME"
exit 1
fi
# set environment variables CUDA_VISIBLE_DEVICES=""
export CUDA_VISIBLE_DEVICES=""
echo "CUDA_VISIBLE_DEVICES: $CUDA_VISIBLE_DEVICES"
if [ $MODEL = "tensorflow" ]; then
BACKEND="xla"
RECORD="$(pwd)/data/tf_records"
elif [ $MODEL = "torch" ]; then
BACKEND="torchjit"
RECORD="$(pwd)/data/torch_records"
else
echo "MODEL must be tensorflow or torch"
exit 1
fi
mkdir $(pwd)/gen -p
# attempt at most 32 times
for i in {1..32}
do
echo "Attempt $i"
PYTHONPATH=$(pwd):$(pwd)/neuri python neuri/cli/fuzz.py fuzz.time=${TIME} fuzz.root=$(pwd)/gen/${MODEL}-${METHOD}-n${NSIZE} \
mgen.record_path=${RECORD} \
fuzz.save_test=$(pwd)/gen/${MODEL}-${METHOD}-n${NSIZE}.models \
model.type=${MODEL} backend.type=${BACKEND} filter.type="[nan,dup,inf]" \
debug.viz=true hydra.verbose=fuzz fuzz.resume=true \
mgen.method=${METHOD} mgen.max_nodes=${NSIZE}
if [ $? -eq 0 ]; then
echo "Fuzzing succeeded after $i attempts."
break
else
echo "Fuzzing crashed with exit code $?. Respawning.." >&2
sleep 0.5
fi
done
echo "WAS RUNNING:"
echo "PYTHONPATH=$(pwd):$(pwd)/neuri python neuri/cli/fuzz.py fuzz.time=${TIME} fuzz.root=$(pwd)/gen/${MODEL}-${METHOD}-n${NSIZE} \\
mgen.record_path=${RECORD} \\
fuzz.save_test=$(pwd)/gen/${MODEL}-${METHOD}-n${NSIZE}.models \\
model.type=${MODEL} backend.type=${BACKEND} filter.type="[nan,dup,inf]" \\
debug.viz=true hydra.verbose=fuzz fuzz.resume=true \\
mgen.method=${METHOD} mgen.max_nodes=${NSIZE}"