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

Adding automatic HPVM compile option to Keras frontend

parent 4f3e3d90
No related branches found
No related tags found
No related merge requests found
......@@ -1127,5 +1127,5 @@ def translate_to_approxhpvm(model,
print ("-- ApproxHPVM src : ", src_dir + "approxhpvm_src.cc")
return weights_dir
return src_dir
......@@ -3,6 +3,7 @@
import sys
import os
import shutil
import subprocess
from keras.utils.np_utils import to_categorical
from keras.models import load_model
from frontend.approxhpvm_translator import translate_to_approxhpvm
......@@ -39,18 +40,36 @@ class Benchmark:
# Compiles frontend generated sources
def compileSource(self, working_dir):
src_file = os.getcwd() + "/" + working_dir + "/approxhpvm_src.cc"
target_binary = os.getcwd() + "/" + working_dir + "/HPVM_binary"
approx_conf_file = "tuner_confs.txt"
# 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
FNULL = open(os.devnull, 'w')
try:
subprocess.run([
"approxhpvm.py",
"-h"
], check=True, stdout=FNULL)
except:
print ("\n\n ERROR: Could not find approxhpvm.py (HPVM compile script)!! \n\n")
print ("To Compile, Must set PATH to include approxhpvm.py script. Do the following: ")
print ("**** export PATH=${PATH_TO_YOUR_HPVM_INSTALLATION}/build/bin/:$PATH *****")
sys.exit(1)
try:
subprocess.run([
"approxhpvm.py", src_file, target_binary,
"-t", "tensor", "--conf-file", approx_conf_file
], check=True)
except:
print ("\n\n ERROR: HPVM Compilation Failed!! \n\n")
sys.exit(1)
def printUsage(self):
print ("Usage: python ${benchmark.py} [hpvm_reload|train] [frontend] [compile]")
......
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