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 d2d175725397994c8e76dd33bf79d77fe652aa3e..d3fb690d76773257d1d7b87d566f22386a0b1fcb 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 @@ -4,8 +4,6 @@ import subprocess import sys class Driver: - fp16_swing = 8 - class PrecisionTypes: FP16 = 0 FP32 = 1 @@ -14,6 +12,7 @@ class Driver: class ApproxTypes: PERF = 3 SAMP = 4 + REDUCE = 5 results_time_key = "Time" results_energy_key = "Energy" @@ -65,7 +64,8 @@ class Driver: return "PERF" elif appr == Driver.ApproxTypes.SAMP: return "SAMP" - + elif appr == Driver.ApproxTypes.REDUCE: + return "REDUCE" def driver(self): self.__parse_tensor_layer_file() @@ -207,6 +207,8 @@ class Driver: time, energy = self.__run_promise_simulation(param_val, layer_table_data) total_time += time total_energy += energy + print("Curr promise: ", time, energy) + print("Total promise: ", total_time, total_energy) layer_results.append((total_time, total_energy, ' '.join(layer_as_lst[2:]))) elif Driver.is_gpu(layer_as_lst[1]): @@ -226,11 +228,13 @@ class Driver: curr_layer = Driver.PrecisionTypes.FP16 elif line.find("fp32") != -1: curr_layer = Driver.PrecisionTypes.FP32 - if precision_type == "perf" or precision_type == "samp": # Handle approx type + if precision_type == "perf" or precision_type == "samp" or precision_type == "reduce": # Handle approx type if precision_type == "perf": approx_type = Driver.ApproxTypes.PERF elif precision_type == "samp": approx_type = Driver.ApproxTypes.SAMP + elif precision_type == "reduce": + approx_type = Driver.ApproxTypes.REDUCE curr_layer = Driver.PrecisionTypes.FP16 quant_time, quant_energy = self.__quantize(precision_type, op_number, curr_layer, prev_layer, tensor_count, layer_table_data) if quant_time != 0: @@ -240,7 +244,6 @@ class Driver: 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 - line = config_file.readline().strip() prev_layer = curr_layer curr_conf_results.append((layer_as_lst[1], layer_results)) @@ -284,7 +287,8 @@ class Driver: or prev_layer == Driver.PrecisionTypes.PROMISE: return 0.0, 0.0 layer_name = layer_data["Name"] - + print("QUANTIZATION") + print(precision_type, op_number, self.__get_str(curr_layer), self.__get_str(prev_layer), h2f_f2h_operation_ind, layer_data) # NOTE: Ignoring logic where curr == promise or prev == promise bc # smartDMA is always true so we'd return near the beginning of the method @@ -346,12 +350,14 @@ class Driver: time_key = None energy_key = None - if approx_type == Driver.ApproxTypes.PERF or approx_type == Driver.ApproxTypes.SAMP: # fp16_perf2_energy + if approx_type == Driver.ApproxTypes.PERF or approx_type == Driver.ApproxTypes.SAMP or approx_type == Driver.ApproxTypes.REDUCE: # fp16_perf2_energy approx_type_str = None if approx_type == Driver.ApproxTypes.PERF: approx_type_str = "perf" elif approx_type == Driver.ApproxTypes.SAMP: approx_type_str = "samp" + elif approx_type == Driver.ApproxTypes.REDUCE: + approx_type_str = "reduce" if curr_layer == Driver.PrecisionTypes.FP32: time_key = "fp32_%s%s_time" % (approx_type_str, knob_number) @@ -480,8 +486,9 @@ class Driver: write_conf_to_file(conf_name, baseline_conf, 1, 1) else: curr_conf = self.__conf_results[conf_index] #conf_name] - #final_time, final_energy, = get_baseline_times_energies(curr_conf) - final_time, final_energy, curr_conf = get_final_times_energies_conf(curr_conf, conf_name) + final_time, final_energy, = get_baseline_times_energies(curr_conf) + print("Baseline time: %f, final time: %f, baseline energy: %f, final energy: %f" % (baseline_total_time, final_time, baseline_total_energy, final_energy)) + #final_time, final_energy, curr_conf = get_final_times_energies_conf(curr_conf, conf_name) write_conf_to_file(conf_name, curr_conf, baseline_total_time / final_time, baseline_total_energy / final_energy) conf_index += 1 results_file.close()