diff --git a/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py b/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py index e7177d1ca2d632a629178926f23a7827a1c71564..18ba65b30704a4b32b4525caf9038e0f69d61bbf 100644 --- a/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py +++ b/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py @@ -6,7 +6,12 @@ import shutil from collections import defaultdict class TableGenerator: - + + __ops_header_delimiter = "#" + __table_header_delimter = "**" + __time_col_name = "time" + __energy_col_name = "energy" + ''' Stores all precision conversions used. ''' @@ -37,8 +42,8 @@ class TableGenerator: self.__table = self.__build_nested_default_dict() - def generate_table(self): - ''' + def generate_table(self): + ''' Generates a table file called <network_name>_tensors.txt in the following steps: 1. Runs the offline profiler against the inputted binaries to generate @@ -47,7 +52,7 @@ class TableGenerator: the offline profiler generated 3. Writes the internal table to <network_name>_tensors.txt file and uses the <network_name>_ops.txt file as a guideline in terms of row order - ''' + ''' #self.__run_inputted_binaries() self.__build_internal_table() self.__output_table_to_file() @@ -115,13 +120,13 @@ class TableGenerator: exit(1) # Store f2h and h2f as columns in the row belonging to the original operation - self.__table[orig_op_name][approx_type]["time"] = total_time - self.__table[orig_op_name][approx_type]["energy"] = total_energy + self.__table[orig_op_name][approx_type][TableGenerator.__time_col_name] = total_time + self.__table[orig_op_name][approx_type][TableGenerator.__energy_col_name] = total_energy # Create a new row in the dictionary else: - self.__table[op_name][approx_type]["time"] = total_time - self.__table[op_name][approx_type]["energy"] = total_energy + self.__table[op_name][approx_type][TableGenerator.__time_col_name] = total_time + self.__table[op_name][approx_type][TableGenerator.__energy_col_name] = total_energy results_file.close() @@ -156,7 +161,7 @@ class TableGenerator: # The header is only generated for the first operation in the layer # CRITICAL ASSUMPTION: All operations within a layer have the same # columns # or everything breaks bc the header is per layer, not per operation - header = ["**", layer_name, str(num_ops)] + header = [TableGenerator.__table_header_delimter, layer_name, str(num_ops)] # Iterate through all operations within the layer for op_in_layer_count in range(num_ops): @@ -170,8 +175,8 @@ class TableGenerator: # Iterate through time/energy data for each approximation type corresponding # to the current operation for approx_type in operation_data: - op_time = operation_data[approx_type]["time"] - op_energy = operation_data[approx_type]["energy"] + op_time = operation_data[approx_type][TableGenerator.__time_col_name] + op_energy = operation_data[approx_type][TableGenerator.__energy_col_name] curr_op.append(op_time) curr_op.append(op_energy) @@ -273,7 +278,7 @@ class TableGenerator: number of ops in the layer ''' comma_ind = layer_info_line.find(",") - return layer_info_line[layer_info_line.find("#") + 1 : comma_ind], \ + return layer_info_line[layer_info_line.find(TableGenerator.__ops_header_delimiter) + 1 : comma_ind], \ int(layer_info_line[comma_ind + 1 : ]) @@ -282,5 +287,4 @@ if __name__ == "__main__": num_iters = 1 profiler_binary_name = "/home/nvidia/awesome_profiler/pp" table_gen = TableGenerator(binary_dir_path, num_iters, profiler_binary_name) - #table_gen.run_inputted_binaries() table_gen.generate_table()