From 6317f0fda7ed87cc224084dd20148b5732380228 Mon Sep 17 00:00:00 2001 From: Elizabeth <hashim.sharif91@gmail.com> Date: Tue, 19 Nov 2019 17:51:58 -0600 Subject: [PATCH] Added code to handle fp32 baseline conv --- .../src/driver_new_config_fp16_repl.py | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/llvm/projects/soc_simulator/src/driver_new_config_fp16_repl.py b/llvm/projects/soc_simulator/src/driver_new_config_fp16_repl.py index 8d7c6ee83c..d6c3d63112 100644 --- a/llvm/projects/soc_simulator/src/driver_new_config_fp16_repl.py +++ b/llvm/projects/soc_simulator/src/driver_new_config_fp16_repl.py @@ -241,6 +241,7 @@ class Driver: assert i == 2 #and layer_ind == 0 conv_time, conv_energy = self.__run_gpu_simulation(curr_layer, layer_name, \ tensor_count, approx_type, op_number) + print(quant_time, conv_time) layer_results.append((quant_time + conv_time, quant_energy + conv_energy, ' '.join(layer_as_lst[i : i + 3]))) prev_layer = curr_layer tensor_count += 1 @@ -309,8 +310,10 @@ class Driver: elif curr_layer == Driver.PrecisionTypes.FP16: time_key = "f2h%stime" % lookup_key energy_key = "f2h%senergy" % lookup_key + print(tensor_op_row) time = tensor_op_row[time_key] energy = tensor_op_row[energy_key] + print(time_key, energy_key) return (time, energy) @@ -411,7 +414,7 @@ class Driver: conf_str.append("-----\n") results_file.write('\n'.join(conf_str)) - baseline_conf = None + fp32_baseline_conf = None baseline_total_time = baseline_total_energy = 0 def get_baseline_times_energies(conf): @@ -441,29 +444,41 @@ class Driver: baseline_time = 0 baseline_energy = 0 baseline_op = [] - baseline_layer = self.fp16_baseline[layer_ind][1] + + if tensor_op.find("fp32") != -1: + assert False + baseline_layer = fp32_baseline_conf[layer_ind][1] + else: + baseline_layer = self.fp16_baseline[layer_ind][1] for op_time, op_energy, tensor_op in baseline_layer: baseline_time += op_time baseline_energy += op_energy baseline_op.append(tensor_op) else: # look at the individual tensor operation as before - baseline_time = self.fp16_baseline[layer_ind][1][tensor_ind][0] - baseline_energy = self.fp16_baseline[layer_ind][1][tensor_ind][1] - baseline_op = self.fp16_baseline[layer_ind][1][tensor_ind][2] + if tensor_op.find("fp32") != -1: + assert False + baseline_layer = fp32_baseline_conf[1][layer_ind] + else: + baseline_layer = self.fp16_baseline[layer_ind][1] + baseline_time = baseline_layer[tensor_ind][0] + baseline_energy = baseline_layer[tensor_ind][1] + baseline_op = baseline_layer[tensor_ind][2] final_tensor_op = tensor_op if op_time > baseline_time: - #print("**************** BIGGER ******************") - #if tensor_op.find("promise") != -1: - # print("WARNING: PROMISE") - #print(curr_conf_name) - #print(baseline_time, baseline_energy, baseline_op, layer_ind) - #print(op_time, tensor_op, layer_ind) + print("**************** BIGGER ******************") + print(curr_conf_name) + print(baseline_time, baseline_energy, baseline_op, layer_ind) + print(op_time, tensor_op, layer_ind) final_time += baseline_time final_energy += baseline_energy final_tensor_op = baseline_op else: + print("**************** SMALLER ******************") + print(curr_conf_name) + print(baseline_time, baseline_energy, baseline_op, layer_ind) + print(op_time, tensor_op, layer_ind) final_time += op_time final_energy += op_energy @@ -479,11 +494,11 @@ class Driver: orig_line_lst = line.split(' ') conf_name = orig_line_lst[0] - if not baseline_conf: - baseline_conf = self.__conf_results[conf_index] #conf_name] - baseline_total_time, baseline_total_energy = get_baseline_times_energies(baseline_conf) + if not fp32_baseline_conf: + fp32_baseline_conf = self.__conf_results[conf_index] #conf_name] + baseline_total_time, baseline_total_energy = get_baseline_times_energies(fp32_baseline_conf) results_file.write("%s\n" % repr(baseline_total_time)) - write_conf_to_file(conf_name, baseline_conf, 1, 1) + write_conf_to_file(conf_name, fp32_baseline_conf, 1, 1) else: curr_conf = self.__conf_results[conf_index] #conf_name] final_time, final_energy, curr_conf = get_final_times_energies_conf(curr_conf, conf_name) -- GitLab