Skip to content
Snippets Groups Projects
Commit d6f074b2 authored by Akash Kothari's avatar Akash Kothari
Browse files

Scripts to automate testing of CNN benchmark

parent 2fc4c0c9
No related branches found
No related tags found
No related merge requests found
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
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment