From bb302f7c267ef751d7044055ed632f4518994685 Mon Sep 17 00:00:00 2001 From: Ubuntu <ubuntu@ip-172-31-4-41.us-east-2.compute.internal> Date: Fri, 11 Oct 2019 05:00:37 +0000 Subject: [PATCH] Adding option for running Baseline Autotuner --- .../bin/tuner_src/benchmarks.py | 54 +++++++------- .../bin/tuner_src/run_autotuner.py | 71 ++++++++++--------- .../bin/tuner_src/run_hs_tuner.py | 26 ++++--- 3 files changed, 84 insertions(+), 67 deletions(-) diff --git a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/benchmarks.py b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/benchmarks.py index 55daa05dc6..eeca0ed8ed 100644 --- a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/benchmarks.py +++ b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/benchmarks.py @@ -7,8 +7,8 @@ # Batch 12: Error Sens: 10, 25, 35, for Loss1, 2, 3, respectively, Min: P3. 1000 Runs for All # Batch 13: No Error Sens: Equal Runs (1000) for all. Min: P1 # Batch 14: Reruning Batch12 with bugFix! -# Batch 15: MAJOR CHANGE: 3 different skip levels for each Loss1,Loss2,Loss3 - +# Batch 16: MAJOR CHANGE: 3 different skip levels for each Loss1,Loss2,Loss3 +# Batch 17: Baseline with 3000 runs. Compare with Batch16 class Benchmark: @@ -46,9 +46,9 @@ Alexnet1.skip_layers = 0 Alexnet1.skip_layer_str = "5_0" Alexnet1.base_dir = "../build_tuner/tuner_results/alexnet_cifar10/" -Alexnet1.result_dir_1 = "../build_tuner/tuner_results/alexnet_cifar10/loss_1/batch15" -Alexnet1.result_dir_2 = "../build_tuner/tuner_results/alexnet_cifar10/loss_2/batch15" -Alexnet1.result_dir_3 = "../build_tuner/tuner_results/alexnet_cifar10/loss_3/batch15" +Alexnet1.result_dir_1 = "../build_tuner/tuner_results/alexnet_cifar10/loss_1/batch17" +Alexnet1.result_dir_2 = "../build_tuner/tuner_results/alexnet_cifar10/loss_2/batch17" +Alexnet1.result_dir_3 = "../build_tuner/tuner_results/alexnet_cifar10/loss_3/batch17" Alexnet1.tensor_desc_file = "tuner_results/alexnet_cifar10/alexnet_tensors.txt" Alexnet1.layer_file = "tuner_results/alexnet_cifar10/alexnet_layers.txt" @@ -79,9 +79,9 @@ Alexnet2.start_promise_range = 1 Alexnet2.skip_layer_str = "6_1_0" Alexnet2.base_dir = "../build_tuner/tuner_results/alexnet2_cifar10/" -Alexnet2.result_dir_1 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_1/batch15" -Alexnet2.result_dir_2 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_2/batch15" -Alexnet2.result_dir_3 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_3/batch15" +Alexnet2.result_dir_1 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_1/batch17" +Alexnet2.result_dir_2 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_2/batch17" +Alexnet2.result_dir_3 = "../build_tuner/tuner_results/alexnet2_cifar10/loss_3/batch17" Alexnet2.tensor_desc_file = "tuner_results/alexnet2_cifar10/alexnet2_tensors.txt" Alexnet2.layer_file = "tuner_results/alexnet2_cifar10/alexnet2_layers.txt" Alexnet2.cost_file = "../build_tuner/tuner_results/alexnet2_cifar10/op_cost.txt" @@ -109,9 +109,9 @@ Alexnet3.start_promise_range = 1 Alexnet3.skip_layer_str = "14_3_4_1_6" Alexnet3.base_dir = "../build_tuner/tuner_results/vgg16_cifar10/" -Alexnet3.result_dir_1 = "../build_tuner/tuner_results/vgg16_cifar10/loss_1/batch15" -Alexnet3.result_dir_2 = "../build_tuner/tuner_results/vgg16_cifar10/loss_2/batch15" -Alexnet3.result_dir_3 = "../build_tuner/tuner_results/vgg16_cifar10/loss_3/batch15" +Alexnet3.result_dir_1 = "../build_tuner/tuner_results/vgg16_cifar10/loss_1/batch17" +Alexnet3.result_dir_2 = "../build_tuner/tuner_results/vgg16_cifar10/loss_2/batch17" +Alexnet3.result_dir_3 = "../build_tuner/tuner_results/vgg16_cifar10/loss_3/batch17" Alexnet3.tensor_desc_file = "tuner_results/vgg16_cifar10/vgg16_tensors.txt" Alexnet3.layer_file = "tuner_results/vgg16_cifar10/vgg16_layers.txt" @@ -141,11 +141,11 @@ Alexnet4.start_promise_range = 1 #Alexnet4.skip_layer_str = "0" Alexnet4.skip_layer_str = "0_1_2_14_15_17_18_21" Alexnet4.base_dir = "../build_tuner/tuner_results/resnet18_cifar10/" -Alexnet4.result_dir_1 = "../build_tuner/tuner_results/resnet18_cifar10/loss_1/batch15" -Alexnet4.result_dir_2 = "../build_tuner/tuner_results/resnet18_cifar10/loss_2/batch15" -Alexnet4.result_dir_3 = "../build_tuner/tuner_results/resnet18_cifar10/loss_3/batch15" +Alexnet4.result_dir_1 = "../build_tuner/tuner_results/resnet18_cifar10/loss_1/batch17" +Alexnet4.result_dir_2 = "../build_tuner/tuner_results/resnet18_cifar10/loss_2/batch17" +Alexnet4.result_dir_3 = "../build_tuner/tuner_results/resnet18_cifar10/loss_3/batch17" Alexnet4.tensor_desc_file = "tuner_results/resnet18_cifar10/resnet_tensors.txt" -Alexnet4.layer_file = "tuner_results/resnet18_cifar10/resnet_layers.txt" +Alexnet4.layer_file = "tuner_results/resnet18_cifar10/resnet18_layers.txt" Alexnet4.cost_file = "../build_tuner/tuner_results/resnet18_cifar10/op_cost.txt" Alexnet4.loss1_result_file = "tuner_results/resnet18_cifar10/loss_1/promise_tuned_confs/promise_confs.txt" @@ -174,9 +174,9 @@ Alexnet5.start_promise_range = 1 #Alexnet5.skip_layer_str = "0" Alexnet5.skip_layer_str = "0_1_2_3_4" Alexnet5.base_dir = "../build_tuner/tuner_results/vgg16_cifar100/" -Alexnet5.result_dir_1 = "../build_tuner/tuner_results/vgg16_cifar100/loss_1/batch15" -Alexnet5.result_dir_2 = "../build_tuner/tuner_results/vgg16_cifar100/loss_2/batch15" -Alexnet5.result_dir_3 = "../build_tuner/tuner_results/vgg16_cifar100/loss_3/batch15" +Alexnet5.result_dir_1 = "../build_tuner/tuner_results/vgg16_cifar100/loss_1/batch17" +Alexnet5.result_dir_2 = "../build_tuner/tuner_results/vgg16_cifar100/loss_2/batch17" +Alexnet5.result_dir_3 = "../build_tuner/tuner_results/vgg16_cifar100/loss_3/batch17" Alexnet5.tensor_desc_file = "../build_tuner/tuner_results/vgg16_cifar100/vgg16_tensors.txt" Alexnet5.layer_file = "../build_tuner/tuner_results/vgg16_cifar100/vgg16_layers.txt" @@ -206,9 +206,9 @@ Alexnet6.start_promise_range = 1 Alexnet6.skip_layer_str = "0" Alexnet6.base_dir = "../build_tuner/tuner_results/lenet_keras/" -Alexnet6.result_dir_1 = "../build_tuner/tuner_results/lenet_keras/loss_1/batch15" -Alexnet6.result_dir_2 = "../build_tuner/tuner_results/lenet_keras/loss_2/batch15" -Alexnet6.result_dir_3 = "../build_tuner/tuner_results/lenet_keras/loss_3/batch15" +Alexnet6.result_dir_1 = "../build_tuner/tuner_results/lenet_keras/loss_1/batch17" +Alexnet6.result_dir_2 = "../build_tuner/tuner_results/lenet_keras/loss_2/batch17" +Alexnet6.result_dir_3 = "../build_tuner/tuner_results/lenet_keras/loss_3/batch17" Alexnet6.tensor_desc_file = "tuner_results/lenet_keras/lenet_tensors.txt" Alexnet6.layer_file = "tuner_results/lenet_keras/lenet_layers.txt" @@ -239,9 +239,9 @@ Alexnet7.start_promise_range = 1 #Alexnet7.skip_layer_str = "0" Alexnet7.skip_layer_str = "1_14_0_6_2" Alexnet7.base_dir = "../build_tuner/tuner_results/mobilenet/" -Alexnet7.result_dir_1 = "../build_tuner/tuner_results/mobilenet/loss_1/batch15" -Alexnet7.result_dir_2 = "../build_tuner/tuner_results/mobilenet/loss_2/batch15" -Alexnet7.result_dir_3 = "../build_tuner/tuner_results/mobilenet/loss_3/batch15" +Alexnet7.result_dir_1 = "../build_tuner/tuner_results/mobilenet/loss_1/batch17" +Alexnet7.result_dir_2 = "../build_tuner/tuner_results/mobilenet/loss_2/batch17" +Alexnet7.result_dir_3 = "../build_tuner/tuner_results/mobilenet/loss_3/batch17" Alexnet7.tensor_desc_file = "tuner_results/mobilenet/mobilenet_ops.txt" Alexnet7.layer_file = "tuner_results/mobilenet/mobilenet_layer_comp.txt" @@ -271,9 +271,9 @@ Alexnet8.start_promise_range = 1 #Alexnet8.skip_layer_str = "0" Alexnet8.skip_layer_str = "7_0_1" Alexnet8.base_dir = "../build_tuner/tuner_results/mobilenet_shallow/" -Alexnet8.result_dir_1 = "../build_tuner/tuner_results/mobilenet_shallow/loss_1/batch15" -Alexnet8.result_dir_2 = "../build_tuner/tuner_results/mobilenet_shallow/loss_2/batch15" -Alexnet8.result_dir_3 = "../build_tuner/tuner_results/mobilenet_shallow/loss_3/batch15" +Alexnet8.result_dir_1 = "../build_tuner/tuner_results/mobilenet_shallow/loss_1/batch17" +Alexnet8.result_dir_2 = "../build_tuner/tuner_results/mobilenet_shallow/loss_2/batch17" +Alexnet8.result_dir_3 = "../build_tuner/tuner_results/mobilenet_shallow/loss_3/batch17" Alexnet8.tensor_desc_file = "../build_tuner/tuner_results/mobilenet_shallow/mobilenet_shallow_ops.txt" Alexnet8.layer_file = "../build_tuner/tuner_results/mobilenet_shallow/mobilenet_shallow_layer_comp.txt" diff --git a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_autotuner.py b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_autotuner.py index 0b59ff187d..2d4a3bb9ca 100644 --- a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_autotuner.py +++ b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_autotuner.py @@ -52,42 +52,44 @@ def computeLayerSwings(): - +gpu = 1 def runPromiseTuner(): - start = startProfile("LeNet") - runPromiseBench(bench_tuner_data["lenet_keras"]) - stopProfile("LeNet", start) + if gpu == 2: + start = startProfile("LeNet") + runPromiseBench(bench_tuner_data["lenet_keras"]) + stopProfile("LeNet", start) - start = startProfile("Alexnet") - runPromiseBench(bench_tuner_data["alexnet_cifar10"]) - stopProfile("Alexnet", start) - - start = startProfile("Alexnet2") - runPromiseBench(bench_tuner_data["alexnet2_cifar10"]) - stopProfile("Alexnet2", start) - - start = startProfile("VGG16_10") - runPromiseBench(bench_tuner_data["vgg16_cifar10"]) - stopProfile("VGG16_10", start) + start = startProfile("Alexnet") + runPromiseBench(bench_tuner_data["alexnet_cifar10"]) + stopProfile("Alexnet", start) - start = startProfile("VGG16_100") - runPromiseBench(bench_tuner_data["vgg16_cifar100"]) - stopProfile("VGG16_100", start) + start = startProfile("Alexnet2") + runPromiseBench(bench_tuner_data["alexnet2_cifar10"]) + stopProfile("Alexnet2", start) - start = startProfile("ResNet") - runPromiseBench(bench_tuner_data["resnet18_cifar10"]) - stopProfile("ResNet", start) + start = startProfile("ResNet") + runPromiseBench(bench_tuner_data["resnet18_cifar10"]) + stopProfile("ResNet", start) - start = startProfile("MobileNet") - runPromiseBench(bench_tuner_data["mobilenet_cifar10"]) - stopProfile("MobileNet", start) + if gpu == 1: + + start = startProfile("VGG16_10") + runPromiseBench(bench_tuner_data["vgg16_cifar10"]) + stopProfile("VGG16_10", start) + + start = startProfile("VGG16_100") + runPromiseBench(bench_tuner_data["vgg16_cifar100"]) + stopProfile("VGG16_100", start) - start = startProfile("MobileNet-SH") - runPromiseBench(bench_tuner_data["mobilenet_shallow"]) - stopProfile("MobileNet-SH", start) + start = startProfile("MobileNet") + runPromiseBench(bench_tuner_data["mobilenet_cifar10"]) + stopProfile("MobileNet", start) + start = startProfile("MobileNet-SH") + runPromiseBench(bench_tuner_data["mobilenet_shallow"]) + stopProfile("MobileNet-SH", start) #runPSNRPromiseBench("pipeline_GEOM") #runPSNRPromiseBench("pipeline_GEMO") @@ -95,7 +97,7 @@ def runPromiseTuner(): #runPSNRPromiseBench("pipeline_GSM") #runPSNRPromiseBench("pipeline_GSME") - dumpProfiles("time_profile_11.txt") + dumpProfiles("time_profile_17.txt") def runPromiseValidation(): @@ -134,6 +136,7 @@ def runAutotuner(): def runSensAnalysis(): + """ start = startProfile("LeNet") test_sensitivity3(bench_tuner_data["lenet_keras"]) stopProfile("LeNet", start) @@ -145,7 +148,8 @@ def runSensAnalysis(): start = startProfile("AlexNet2") test_sensitivity3(bench_tuner_data["alexnet2_cifar10"]) stopProfile("AlexNet2", start) - + """ + start = startProfile("ResNet") test_sensitivity3(bench_tuner_data["resnet18_cifar10"]) stopProfile("ResNet", start) @@ -159,6 +163,7 @@ def runSensAnalysis(): test_sensitivity3(bench_tuner_data["mobilenet_shallow"]) stopProfile("MobileNet_SH", start) + """ start = startProfile("VGG_10") test_sensitivity3(bench_tuner_data["vgg16_cifar10"]) stopProfile("VGG16_10", start) @@ -166,7 +171,9 @@ def runSensAnalysis(): start = startProfile("VGG_100") test_sensitivity3(bench_tuner_data["vgg16_cifar100"]) stopProfile("VGG16_100", start) - + + """ + dumpProfiles("sens_time_prof.txt") @@ -206,9 +213,9 @@ if __name__ == "__main__": #computeLayerSwings() - #runPromiseTuner() + runPromiseTuner() - runPromiseValidation() + #runPromiseValidation() #runSensAnalysis() diff --git a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_hs_tuner.py b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_hs_tuner.py index ae06613aaf..f1a9c8f417 100644 --- a/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_hs_tuner.py +++ b/llvm/projects/hpvm-tensor-rt/bin/tuner_src/run_hs_tuner.py @@ -7,7 +7,7 @@ from error_sensitivity import select_skip_layers def runPromiseTunerCmd(Bench, dir_prefix, result_dir, acc_threshold, autotuner_runs, skip_layers): - tuner_cmd = "python ../opentuner/autotuner/promise_tuner3.py " + tuner_cmd = "python2 ../opentuner/autotuner/promise_tuner3.py " tuner_cmd += " --test-limit " tuner_cmd += str(autotuner_runs) tuner_cmd += " --binary ./" @@ -48,7 +48,7 @@ def runPromiseTunerCmd(Bench, dir_prefix, result_dir, acc_threshold, autotuner_r def promiseTunerLoss1(Bench, dir_prefix): - tuner_runs = int(Bench.autotuner_runs / 3) + tuner_runs = Bench.autotuner_runs skip_layers1 = "0" skip_layers2 = "0_" + select_skip_layers(Bench, 30) @@ -61,7 +61,7 @@ def promiseTunerLoss1(Bench, dir_prefix): def promiseTunerLoss2(Bench, dir_prefix): - tuner_runs = int(Bench.autotuner_runs / 3) + tuner_runs = Bench.autotuner_runs skip_layers1 = "0" skip_layers2 = "0_" + select_skip_layers(Bench, 20) @@ -75,7 +75,7 @@ def promiseTunerLoss2(Bench, dir_prefix): def promiseTunerLoss3(Bench, dir_prefix): - tuner_runs = int(Bench.autotuner_runs / 3) + tuner_runs = Bench.autotuner_runs skip_layers1 = "0" skip_layers2 = "0_" + select_skip_layers(Bench, 10) @@ -86,6 +86,7 @@ def promiseTunerLoss3(Bench, dir_prefix): runPromiseTunerCmd(Bench, dir_prefix, Bench.result_dir_3, 2.5, tuner_runs, skip_layers3) +BASELINE = True def runPromiseBench(Bench): @@ -93,12 +94,21 @@ def runPromiseBench(Bench): # NOTE-IMP: Changing current directory to one with promise binaries dir_prefix = "../build_tuner/" - - promiseTunerLoss1(Bench, dir_prefix) - promiseTunerLoss2(Bench, dir_prefix) + if BASELINE: + tuner_runs = Bench.autotuner_runs * 2 + skip_layers = "0" + runPromiseTunerCmd(Bench, dir_prefix, Bench.result_dir_1, 0.85, tuner_runs, skip_layers) + runPromiseTunerCmd(Bench, dir_prefix, Bench.result_dir_2, 1.7, tuner_runs, skip_layers) + runPromiseTunerCmd(Bench, dir_prefix, Bench.result_dir_3, 2.5, tuner_runs, skip_layers) + + else: + + promiseTunerLoss1(Bench, dir_prefix) + + promiseTunerLoss2(Bench, dir_prefix) - promiseTunerLoss3(Bench, dir_prefix) + promiseTunerLoss3(Bench, dir_prefix) -- GitLab