From d6f074b2eae2294f97dee3ca9c7f2139faa6938b Mon Sep 17 00:00:00 2001 From: Akash Kothari <akashk4@tyler.cs.illinois.edu> Date: Mon, 14 Dec 2020 14:13:26 -0600 Subject: [PATCH] Scripts to automate testing of CNN benchmark --- .../DNN_Benchmarks/benchmarks/run_dnn_pred.py | 70 +++++++++++++++++++ .../benchmarks/run_dnns_pred.py | 13 ++++ 2 files changed, 83 insertions(+) create mode 100644 llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnn_pred.py create mode 100644 llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnns_pred.py diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnn_pred.py b/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnn_pred.py new file mode 100644 index 0000000000..1cb3b5d4ec --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnn_pred.py @@ -0,0 +1,70 @@ +import os.path +from os import path +import sys + +temp_file_name = "temp.txt" + +def max_num_configs (config_file): + num_configs = 0 + with open(config_file, "r") as f: + for line in f: + if "conf" in line: + num_configs = num_configs + 1 + return (num_configs + 1) + + +def read_and_write_config (config_file, config_num, temp_file): + config = "" + with open(config_file, "r") as f: + conf = "conf" + str(config_num) + read_config = False + read_first_line = False + for line in f: + if read_first_line == False: + config = config + line + read_first_line = True + continue + if "-----" in line and read_config == True: + read_config = False + config = config + line + break + if read_config == True: + config = config + line + continue + if conf in line: + read_config = True + config = config + line + print("config: ") + print(config) + with open(temp_file, "w") as f: + f.write(config) + + +if __name__ == "__main__": + num_args = len(sys.argv) + binary_files = list() + bench_dir = sys.argv[1] + print(bench_dir) + arg = 2 + while arg < num_args: + binary_files.append(sys.argv[arg]) + arg = arg + 1 + + for dnn_name in binary_files: + binary_dir = bench_dir + "/" + dnn_name + pred_dir = binary_dir + "/predictive" + config_file = pred_dir + "/" + dnn_name + ".txt" + temp_file = pred_dir + "/" + temp_file_name + print("binary_dir: " + binary_dir) + print("pred_dir: " + pred_dir) + print("config_file: " + config_file) + print("temp_file: " + temp_file) + config_num = 1 + max_configs = max_num_configs(config_file) + while config_num < max_configs: + read_and_write_config(config_file, config_num, temp_file) + exec_command = binary_dir + " " + temp_file + print(exec_command) + os.system(exec_command) + config_num = config_num + 1 + diff --git a/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnns_pred.py b/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnns_pred.py new file mode 100644 index 0000000000..29617bd8e4 --- /dev/null +++ b/llvm/test/VISC/DNN_Benchmarks/benchmarks/run_dnns_pred.py @@ -0,0 +1,13 @@ +import os.path +from os import path + +#dnns = "alexnet alexnet2 vgg16_cifar10 vgg16_cifar100 resnet18 mobilenet lenet_mnist" +dnns = "alexnet" + +cur_dir = "/home/akashk4/merge/profiling/hpvm/llvm/test/VISC/DNN_Benchmarks/benchmarks" + +if __name__ == "__main__": + exec_command = "python3 run_dnn_pred.py" + " " + cur_dir + " " + dnns + print(exec_command) + os.system(exec_command) + -- GitLab