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

Adding automatic extraction of devtime knobs

parent eb51912d
No related branches found
No related tags found
No related merge requests found
fp32,11 -1 1.0 tensorConvolution tensorConvApprox
fp16,12 -1 1.5 tensorConvolution tensorConvApproxHalf2
perf,121 1,2,0 2.0 tensorConvolution tensorConvApprox
perf,122 1,2,1 2.0 tensorConvolution tensorConvApprox
perf,123 2,1,0 2.0 tensorConvolution tensorConvApprox
perf,124 2,1,1 2.0 tensorConvolution tensorConvApprox
perf,125 1,3,0 1.5 tensorConvolution tensorConvApprox
perf,126 1,3,1 1.5 tensorConvolution tensorConvApprox
perf,127 1,3,2 1.5 tensorConvolution tensorConvApprox
perf,128 3,1,0 1.5 tensorConvolution tensorConvApprox
perf,129 3,1,1 1.5 tensorConvolution tensorConvApprox
perf,130 3,1,2 1.5 tensorConvolution tensorConvApprox
perf,131 1,4,0 1.33 tensorConvolution tensorConvApprox
perf,132 1,4,1 1.33 tensorConvolution tensorConvApprox
perf,133 1,4,2 1.33 tensorConvolution tensorConvApprox
perf,134 1,4,3 1.33 tensorConvolution tensorConvApprox
perf,135 4,1,0 1.33 tensorConvolution tensorConvApprox
perf,136 4,1,1 1.33 tensorConvolution tensorConvApprox
perf,137 4,1,2 1.33 tensorConvolution tensorConvApprox
perf,138 4,1,3 1.33 tensorConvolution tensorConvApprox
samp,231 2,0 2.0 tensorConvolution tensorConvApprox
samp,232 2,1 2.0 tensorConvolution tensorConvApprox
samp,233 4,0 1.33 tensorConvolution tensorConvApprox
samp,234 4,1 1.33 tensorConvolution tensorConvApprox
samp,235 4,2 1.33 tensorConvolution tensorConvApprox
samp,236 4,3 1.33 tensorConvolution tensorConvApprox
reduction_samp,41 1 1.5
reduction_samp,42 1 2.25
reduction_samp,43 1 1.4
reduction_samp,44 1 2
reduction_samp,45 1 1.25
reduction_samp,46 1 1.8
swing_level,1 1 12
swing_level,2 1 10
swing_level,3 1 9
swing_level,4 1 8
swing_level,5 1 6
swing_level,6 1 5
swing_level,7 1 4
fp32,11 -1 1.0 tensorConvolution tensorConvApprox dev conv_fc_red
fp16,12 -1 1.5 tensorConvolution tensorConvApproxHalf2 install conv_fc_red
perf,121 1,2,0 2.0 tensorConvolution tensorConvApprox dev conv
perf,122 1,2,1 2.0 tensorConvolution tensorConvApprox dev conv
perf,123 2,1,0 2.0 tensorConvolution tensorConvApprox dev conv
perf,124 2,1,1 2.0 tensorConvolution tensorConvApprox dev conv
perf,125 1,3,0 1.5 tensorConvolution tensorConvApprox dev conv
perf,126 1,3,1 1.5 tensorConvolution tensorConvApprox dev conv
perf,127 1,3,2 1.5 tensorConvolution tensorConvApprox dev conv
perf,128 3,1,0 1.5 tensorConvolution tensorConvApprox dev conv
perf,129 3,1,1 1.5 tensorConvolution tensorConvApprox dev conv
perf,130 3,1,2 1.5 tensorConvolution tensorConvApprox dev conv
perf,131 1,4,0 1.33 tensorConvolution tensorConvApprox dev conv
perf,132 1,4,1 1.33 tensorConvolution tensorConvApprox dev conv
perf,133 1,4,2 1.33 tensorConvolution tensorConvApprox dev conv
perf,134 1,4,3 1.33 tensorConvolution tensorConvApprox dev conv
perf,135 4,1,0 1.33 tensorConvolution tensorConvApprox dev conv
perf,136 4,1,1 1.33 tensorConvolution tensorConvApprox dev conv
perf,137 4,1,2 1.33 tensorConvolution tensorConvApprox dev conv
perf,138 4,1,3 1.33 tensorConvolution tensorConvApprox dev conv
samp,231 2,0 2.0 tensorConvolution tensorConvApprox dev conv
samp,232 2,1 2.0 tensorConvolution tensorConvApprox dev conv
samp,233 4,0 1.33 tensorConvolution tensorConvApprox dev conv
samp,234 4,1 1.33 tensorConvolution tensorConvApprox dev conv
samp,235 4,2 1.33 tensorConvolution tensorConvApprox dev conv
samp,236 4,3 1.33 tensorConvolution tensorConvApprox dev conv
red_samp,41 1 1.5 tensorReduction tensorReduction dev red
red_samp,42 1 2.25 tensorReduction tensorReduction dev red
red_samp,43 1 1.4 tensorReduction tensorReduction dev red
red_samp,44 1 2 tensorReduction tensorReduction dev red
red_samp,45 1 1.25 tensorReduction tensorReduction dev red
red_samp,46 1 1.8 tensorReduction tensorReduction dev red
swing_level,1 1 12 tensorConvolution tensorConvApprox install conv_fc
swing_level,2 1 10 tensorConvolution tensorConvApprox install conv_fc
swing_level,3 1 9 tensorConvolution tensorConvApprox install conv_fc
swing_level,4 1 8 tensorConvolution tensorConvApprox install conv_fc
swing_level,5 1 6 tensorConvolution tensorConvApprox install conv_fc
swing_level,6 1 5 tensorConvolution tensorConvApprox install conv_fc
swing_level,7 1 4 tensorConvolution tensorConvApprox install conv_fc
......@@ -19,7 +19,7 @@ class DevTimeTuner:
def __init__(self, Bench):
self.piped_execution = True
self.autotuner_runs = 100000
self.autotuner_runs = 5000
self.promise_binary = Bench.promise_binary
......@@ -32,8 +32,14 @@ class DevTimeTuner:
self.gold_accuracy = Bench.promise_accuracy
self.cost_file = global_paths.tensorRT_dir + "/" + Bench.cost_file
self.layer_file = global_paths.tensorRT_dir + "/" + Bench.layer_file
self.layer_knobs = global_paths.tensorRT_dir + "/" + Bench.layer_knobs
self.result_dir = global_paths.tensorRT_dir + "/" + Bench.base_dir + "/loss_123/" + batch_id + "/dev_tuner/"
#self.layer_knobs = global_paths.tensorRT_dir + "/" + Bench.layer_knobs
global_knobs_file = global_paths.tensorRT_dir + "/autotuner/data/global_knobs.txt"
utils.createDevKnobs(self.layer_file, global_knobs_file, "dev_knobs.txt")
self.layer_knobs = "dev_knobs.txt"
self.result_dir = global_paths.tensorRT_dir + "/" + Bench.base_dir + \
"/loss_123/" + batch_id + "/dev_tuner/"
# NOTE: maintains total iterations completed - across multiple invocations
self.iterations_completed = 0
......@@ -41,7 +47,8 @@ class DevTimeTuner:
self.start_time = 0
def invokeDevTunerScript(self, accuracy_slack, additional_error_slack, autotuner_runs):
def invokeDevTunerScript(self, accuracy_slack, \
additional_error_slack, autotuner_runs):
accuracy_threshold = self.gold_accuracy - accuracy_slack
accuracy_additional_slack = self.gold_accuracy - additional_error_slack
......@@ -62,7 +69,8 @@ class DevTimeTuner:
tuner_cmd += " --cost-file "
tuner_cmd += self.cost_file
tuner_cmd += " --knobs-config "
tuner_cmd += "../autotuner/data/global_knobs.txt"
tuner_cmd += global_paths.tensorRT_dir + "/autotuner/data/global_knobs.txt"
### tuner_cmd += "../autotuner/data/global_knobs.txt"
tuner_cmd += " --layer-knobs "
tuner_cmd += self.layer_knobs
tuner_cmd += " --start-id "
......@@ -124,7 +132,8 @@ class DevTimeTuner:
# Adding an extra loss to tuned configurations - adjusting for unseen data
buildRtConfig.adjustConfigLosses(sorted_configurations)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, config_out_path, bench_layer_composition)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, \
config_out_path, bench_layer_composition)
plot_file_path = self.result_dir + "dev_all_conf_plot.png"
genPlots.genScatterPlotFromConfigs(sorted_configurations, plot_file_path)
......@@ -152,7 +161,8 @@ class DevTimeTuner:
# Adding an extra loss to tuned configurations - adjusting for unseen data
buildRtConfig.adjustConfigLosses(sorted_configurations)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, config_out_path, bench_layer_composition)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, \
config_out_path, bench_layer_composition)
plot_file_path = self.result_dir + "dev_pareto_plot.png"
genPlots.genScatterPlotFromConfigs(sorted_configurations, plot_file_path)
......@@ -177,7 +187,8 @@ class DevTimeTuner:
# Adding an extra loss to tuned configurations - adjusting for unseen data
buildRtConfig.adjustConfigLosses(sorted_configurations)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, config_out_path, bench_layer_composition)
buildRtConfig.dumpDevConfigsToRTFile(sorted_configurations, \
config_out_path, bench_layer_composition)
plot_file_path = self.result_dir + "true_pareto_plot.png"
genPlots.genScatterPlotFromConfigs(sorted_configurations, plot_file_path)
......@@ -197,7 +208,8 @@ class DevTimeTuner:
ref_dir = self.result_dir + "/references/"
utils.createDir(ref_dir)
sources = {"run_devtime_tuner.py", "benchmarks.py", "buildRtConfig.py", "global_paths.py"}
sources = {"run_devtime_tuner.py", "benchmarks.py", \
"buildRtConfig.py", "global_paths.py"}
for src in sources:
src_path = global_paths.tensorRT_dir + "/autotuner/tuner_driver_src/" + src
......
......@@ -103,3 +103,65 @@ def debug_print(str):
if debug_flag == True:
print (str)
def readOpKnobs(global_knobs_file, op_type, analysis_mode):
knobs_file = open(global_knobs_file, "r")
tuning_knobs = []
for knob in knobs_file:
toks = knob.split("\t")
if op_type in toks[-1] and analysis_mode in toks[-2]:
knob_id = toks[0].split(",")[1]
tuning_knobs.append(knob_id)
return tuning_knobs
def readConvKnobs(global_knobs_file, analysis_mode):
return readOpKnobs(global_knobs_file, "conv", analysis_mode)
def readFCKnobs(global_knobs_file, analysis_mode):
return readOpKnobs(global_knobs_file, "fc", analysis_mode)
def readRedKnobs(global_knobs_file, analysis_mode):
return readOpKnobs(global_knobs_file, "red", analysis_mode)
def createDevKnobs(layer_file, global_knobs_file, out_file):
f = open(layer_file, "r")
conv_knobs = readConvKnobs(global_knobs_file, "dev")
fc_knobs = readFCKnobs(global_knobs_file, "dev")
red_knobs = readRedKnobs(global_knobs_file, "dev")
print (conv_knobs, fc_knobs, red_knobs)
f_out = open(out_file, "w+")
for x in f:
if "conv" in x:
f_out.write(",".join(conv_knobs) + "\n")
if "dense" in x:
f_out.write(",".join(fc_knobs) + "\n")
if "red" in x:
f_out.write(",".join(red_knobs) + "\n")
f_out.close()
if __name__ == "__main__":
createDevKnobs("../data/alexnet2/alexnet2_layers.txt", \
"../data/global_knobs.txt", "dev_knobs.txt")
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