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

Adding source compile option (incomplete) to common Benchmark script

parent 611f946d
No related branches found
No related tags found
No related merge requests found
import sys
import os
import shutil
from keras.utils.np_utils import to_categorical
from keras.models import load_model
from frontend.approxhpvm_translator import translate_to_approxhpvm
......@@ -8,7 +10,8 @@ from frontend.weight_utils import dumpCalibrationData
from frontend.weight_utils import dumpHPVMToKerasModel
# Every CNN Benchmark must inherit from Benchmark class
# Defines common interfaces and virtual methods to be overridden by child classes
class Benchmark:
def __init__(self, name, reload_dir, keras_model_file, hpvm_dir, num_classes):
......@@ -32,14 +35,30 @@ class Benchmark:
return
# Compiles frontend generated sources
def compileSource(self, working_dir):
# set LLVM_SRC_ROOT
os.environ["CFLAGS"] = ""
os.environ["CXXFLAGS"] = ""
dest_file = working_dir + "CMakeLists.txt"
shutil.copy("cmake_template/CMakeLists.txt", dest_file)
# Cmake ../
# make
def run(self, argv):
if len(argv) < 2:
print ("Usage: python ${benchmark.py} [hpvm_reload|keras_reload|train] [frontend]")
print ("Usage: python ${benchmark.py} [hpvm_reload|keras_reload|train] [frontend] [compile]")
sys.exit(0)
# Virtual method call implemented by each CNN
model = self.buildModel()
# Virtual method call to preprocess test and train data
X_train, Y_train, X_test, Y_test = self.data_preprocess()
if argv[1] == "hpvm_reload":
......@@ -60,11 +79,12 @@ class Benchmark:
print("ERROR: Must load HPVM model to invoke frontend - use 'hpvm_reload'")
sys.exit(1)
# Main call to ApproxHPVM-Keras Frontend
working_dir = translate_to_approxhpvm(model, self.hpvm_dir, X_test, Y_test, self.num_classes)
print ("*** working_dir = ", working_dir)
if len(argv) > 3 and argv[3] == "compile":
self.compileSource(working_dir)
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