Skip to content
Snippets Groups Projects
Commit 11068a0e authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Pushing Keras test script changes

parent 3234c9a6
No related branches found
No related tags found
No related merge requests found
......@@ -556,10 +556,6 @@ class HPVMTranslator:
headers += "#include <cstring> \n"
headers += "#include <" + HPVM_header + "> \n"
#if LLVM_9_BRANCH:
# headers += "#include \"config.h\" \n"
headers += "#include <tensorTypes.h> \n"
headers += "#include <tensorUtils.h> \n\n"
self.file_header_str = headers
......
......@@ -59,13 +59,13 @@ class Benchmark:
except:
print("""
ERROR: Could not find hpvm-clang (HPVM compile script)!!
ERROR: Could not find hpvm-clang (HPVM compile script)!!
hpvm-clang is installed to the python environment used when compiling HPVM.
Please try rerunning 'make -j hpvm-clang'.""")
hpvm-clang is installed to the python environment used when compiling HPVM.
Please try rerunning 'make -j hpvm-clang' and make sure `hpvm-clang` is in your $PATH""")
sys.exit(1)
try:
subprocess.run([
"hpvm-clang", src_file, target_binary,
......
......@@ -3,8 +3,10 @@ import pathlib
# Path Relative to Model Params Directory
abs_path = pathlib.Path(__file__).parent.absolute()
MODEL_PARAMS_DIR = str(abs_path) + "/../../../../hpvm/test/dnn_benchmarks/model_params/"
CUR_SRC_PATH = str(pathlib.Path(__file__).parent.absolute())
MODEL_PARAMS_DIR = CUR_SRC_PATH + "/../../../../hpvm/test/dnn_benchmarks/model_params/"
if __name__ == "__main__":
......
......@@ -3,25 +3,15 @@
import os
import sys
import subprocess
import site
from pathlib import Path
import torch
from torch.utils.data.dataloader import DataLoader
from torch.utils.data.dataset import Subset
#site.addsitedir(Path(__file__).parent.parent.absolute().as_posix())
#from predtuner import PipedBinaryApp, config_pylogger
from Config import *
class Benchmark:
def __init__(self, binary_path, test_accuracy):
def __init__(self, binary_path, output_dir, test_accuracy):
self.binary_path = binary_path
self.test_accuracy = test_accuracy
self.output_dir = output_dir
self.epsilon = 0.05 # Adding some slack for accuracy difference
......@@ -69,10 +59,14 @@ class Benchmark:
except:
return False
working_dir = open("working_dir.txt").read()
#working_dir = open("working_dir.txt").read()
cur_dir = os.getcwd()
working_dir = self.output_dir
os.chdir(working_dir)
print ("cur_dir = ", os.getcwd())
binary_path = "./HPVM_binary"
try:
......@@ -96,31 +90,6 @@ class Benchmark:
return test_success
"""
def runApproxTuner(self):
working_dir = open("working_dir.txt").read()
cur_dir = os.getcwd()
os.chdir(working_dir)
binary_path = "./HPVM_tuner_binary"
full_binary_path = str(cur_dir) + "/" + working_dir + "/" + binary_path
full_json_path = str(cur_dir) + "/" + working_dir + "/tuner.json"
app = PipedBinaryApp("TestHPVMApp", full_binary_path, full_json_path)
# Tuning procedure is exactly the same as that for PyTorch DNN.
# Please refer to `./tune_vgg16_cifar10.py` for details.
tuner = app.get_tuner()
tuner.tune(5000, 3.0, 3.0, True, 50, cost_model="cost_linear", qos_model="qos_p1")
tuner.dump_configs("configs.json")
fig = tuner.plot_configs(show_qos_loss=True)
fig.savefig("configs.png", dpi=300)
app.dump_hpvm_configs(tuner.best_configs, "hpvm_confs.txt")
os.chdir(cur_dir) # Change back to original working directory
"""
......@@ -202,30 +171,33 @@ if __name__ == "__main__":
print ("Usage: python3 test_dnnbenchmarks.py ${work_dir}")
work_dir = sys.argv[1]
if not os.path.exists(work_dir):
os.mkdir(work_dir)
if os.path.exists(work_dir):
print ("Work Directory Exists. Delete it or use a different work directory.")
sys.exit(0)
os.mkdir(work_dir)
os.chdir(work_dir)
testMgr = BenchmarkTests()
AlexNet = Benchmark("../alexnet.py", 79.28)
AlexNet_ImageNet = Benchmark("../alexnet_imagenet.py", 56.30)
AlexNet2 = Benchmark("../alexnet2.py", 84.98)
LeNet = Benchmark("../lenet.py", 98.70)
MobileNet = Benchmark("../mobilenet_cifar10.py", 84.42)
ResNet18 = Benchmark("../resnet18_cifar10.py", 89.56)
ResNet50 = Benchmark("../resnet50_imagenet.py", 75.10)
VGG16_cifar10 = Benchmark("../vgg16_cifar10.py", 89.96)
VGG16_cifar100 = Benchmark("../vgg16_cifar100.py", 66.50)
VGG16_ImageNet = Benchmark("../vgg16_imagenet.py", 69.46)
testMgr.addBenchmark(AlexNet)
AlexNet = Benchmark(CUR_SRC_PATH + "/alexnet.py", "src/alexnet_cifar10_src_hpvm", 79.28)
AlexNet_ImageNet = Benchmark(CUR_SRC_PATH + "/alexnet_imagenet.py", "src/alexnet_imagenet_src", 56.30)
AlexNet2 = Benchmark(CUR_SRC_PATH + "/alexnet2.py", "src/alexnet2_cifar10_src", 84.98)
LeNet = Benchmark(CUR_SRC_PATH + "/lenet.py", "src/lenet_mnist_src", 98.70)
MobileNet = Benchmark(CUR_SRC_PATH + "/mobilenet_cifar10.py", "src/mobilenet_cifar10_src", 84.42)
ResNet18 = Benchmark(CUR_SRC_PATH + "/resnet18_cifar10.py", "src/resnet18_cifar10_src", 89.56)
ResNet50 = Benchmark(CUR_SRC_PATH + "/resnet50_imagenet.py", "src/resnet50_imagenet_src", 75.10)
VGG16_cifar10 = Benchmark(CUR_SRC_PATH + "/vgg16_cifar10.py", "src/vgg16_cifar10_src", 89.96)
VGG16_cifar100 = Benchmark(CUR_SRC_PATH + "/vgg16_cifar100.py", "src/vgg16_cifar100_src", 66.50)
VGG16_ImageNet = Benchmark(CUR_SRC_PATH + "/vgg16_imagenet.py", "src/vgg16_imagenet_src", 69.46)
#testMgr.addBenchmark(AlexNet)
#testMgr.addBenchmark(AlexNet_ImageNet)
testMgr.addBenchmark(AlexNet2)
#testMgr.addBenchmark(AlexNet2)
testMgr.addBenchmark(LeNet)
testMgr.addBenchmark(MobileNet)
testMgr.addBenchmark(ResNet18)
#testMgr.addBenchmark(MobileNet)
#testMgr.addBenchmark(ResNet18)
#testMgr.addBenchmark(ResNet50)
testMgr.addBenchmark(VGG16_cifar10)
#testMgr.addBenchmark(VGG16_cifar10)
testMgr.addBenchmark(VGG16_cifar100)
#testMgr.addBenchmark(VGG16_ImageNet)
......@@ -235,4 +207,6 @@ if __name__ == "__main__":
testMgr.runHPVMTests()
testMgr.printHPVMSummary()
#testMgr.runKerasTests()
#testMgr.printKerasSummary()
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