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

Adding argparse options to Keras frontend test script

parent 65434337
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
import os import os
import sys import sys
import subprocess import subprocess
import argparse
from Config import * from Config import *
class Benchmark: class Benchmark:
def __init__(self, binary_path, output_dir, test_accuracy): def __init__(self, binary_path, output_dir, test_accuracy):
...@@ -50,10 +52,15 @@ class Benchmark: ...@@ -50,10 +52,15 @@ class Benchmark:
return test_success return test_success
def runHPVM(self): def runHPVM(self, weights_dump):
# Test Bechmark accuracy with pretrained weights (hpvm_relaod) if weights_dump:
run_cmd = "python3 " + self.binary_path + " keras_reload frontend compile compile_tuner" # Test Benchmark with Keras weight dumping
run_cmd = "python3 " + self.binary_path + " keras_reload frontend compile compile_tuner"
else:
# Test Benchmark accuracy with pretrained weights (hpvm_relaod)
run_cmd = "python3 " + self.binary_path + " hpvm_reload frontend compile compile_tuner"
try: try:
subprocess.call(run_cmd, shell=True) subprocess.call(run_cmd, shell=True)
except: except:
...@@ -120,10 +127,10 @@ class BenchmarkTests: ...@@ -120,10 +127,10 @@ class BenchmarkTests:
self.passed_tests.append(benchmark.getPath()) self.passed_tests.append(benchmark.getPath())
def runHPVMTests(self): def runHPVMTests(self, weights_dump):
for benchmark in self.benchmarks: for benchmark in self.benchmarks:
test_success = benchmark.runHPVM() test_success = benchmark.runHPVM(weights_dump)
if not test_success: if not test_success:
self.failed_hpvm_tests.append(benchmark.getPath()) self.failed_hpvm_tests.append(benchmark.getPath())
...@@ -173,10 +180,21 @@ class BenchmarkTests: ...@@ -173,10 +180,21 @@ class BenchmarkTests:
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) < 2:
print ("Usage: python3 test_dnnbenchmarks.py ${work_dir}")
work_dir = sys.argv[1] parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--work-dir', type=str,
help='working dir for dumping frontend generated files')
parser.add_argument('--dump-weights', action="store_true", help='dump h5 weights to bin (default: False)')
args = parser.parse_args()
work_dir = args.work_dir
dump_weights = args.dump_weights
#print (dump_weights)
#sys.exit(0)
if os.path.exists(work_dir): if os.path.exists(work_dir):
print ("Work Directory Exists. Delete it or use a different work directory.") print ("Work Directory Exists. Delete it or use a different work directory.")
sys.exit(0) sys.exit(0)
...@@ -210,12 +228,10 @@ if __name__ == "__main__": ...@@ -210,12 +228,10 @@ if __name__ == "__main__":
#testMgr.runKerasTests() #testMgr.runKerasTests()
#testMgr.printKerasSummary() #testMgr.printKerasSummary()
testMgr.runHPVMTests() testMgr.runHPVMTests(dump_weights)
tests_passed = testMgr.printHPVMSummary() tests_passed = testMgr.printHPVMSummary()
if not tests_passed: if not tests_passed:
sys.exit(-1) sys.exit(-1)
#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