From 835a08cf46a6f21039af1e2694230885a9947663 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Mon, 6 Feb 2023 13:52:41 +0100 Subject: [PATCH] Add generate_binaries.sh --- src/scripts/generate_binaries.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 src/scripts/generate_binaries.sh diff --git a/src/scripts/generate_binaries.sh b/src/scripts/generate_binaries.sh new file mode 100755 index 0000000..35cd144 --- /dev/null +++ b/src/scripts/generate_binaries.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Use with +# ```bash +# $ python -i src/scripts/benchmark_binary.py +# >>> compare_binaries(["binaries/"+i for i in os.listdir("binaries")], tries=10, dataset='train') +# ``` +BIN_OUT=binaries +FILE_TO_MODIFY="src/cnn/include/train.h" +VARIABLE_TO_MODIFY="LEARNING_RATE" + +mkdir -p "$BIN_OUT" +rm -rf "$BIN_OUT"/* + +values="0 5 25 50" # Example values + +for val in $values; do + # For a variable + # sed -i 's/'"$VARIABLE_TO_MODIFY"'=.*/'"$VARIABLE_TO_MODIFY'='$val"';/g' "$FILE_TO_MODIFY" + # For a define + sed -i 's/#define '"$VARIABLE_TO_MODIFY"' .*$/#define '"$VARIABLE_TO_MODIFY"' '"$val"'/g' "$FILE_TO_MODIFY" + make all + cp build/cnn-main "$BIN_OUT"/"$VARIABLE_TO_MODIFY=$val" +done