Skip to content
Snippets Groups Projects
Commit f24a8d81 authored by Elizabeth's avatar Elizabeth
Browse files

Removed functionality to opush h2f/f2h conversions to the back and added keys...

Removed functionality to opush h2f/f2h conversions to the back and added keys for all f2h/h2f conversions
parent ec84ed2b
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,6 @@ class TableGenerator:
self.__table_filename = "%s_tensors.txt" % self.__network_name
def __is_binary(self, file_path):
# Binary name must start with the network name as per our naming standards
return os.path.isfile(file_path) and os.access(file_path, os.X_OK) and \
......@@ -80,7 +79,6 @@ class TableGenerator:
underscore_ind = op_name.find("_")
return op_name[ : underscore_ind], op_name[underscore_ind + 1 : ]
def generate_table(self):
self.__table = self.__build_nested_default_dict()
self.__build_internal_table()
......@@ -101,16 +99,20 @@ class TableGenerator:
line = line.strip()
op_name, total_time, total_energy = self.__parse_tensor_operation_line(line)
# Conv1 --> all approximations --> store f2h and h2f as independent approximations
# Need to store their full names
# Handle _f2h and _h2f output for tensor operation
# Store as columns of original operation rather than independent rows
if any(op_name.endswith(prec_conv) for prec_conv in TableGenerator.precision_conversions):
orig_op_name, conversion_type = self.__get_original_operation_name(op_name)
# Error bc original op name should ALWAYS be in the table
if orig_op_name not in self.__table:
print("ERROR: Conversion found but original %s is not in the table" % orig_op_name)
exit(1)
self.__table[orig_op_name][conversion_type]["time"] = total_time
self.__table[orig_op_name][conversion_type]["energy"] = total_energy
# Need to store f2h and h2f for each type of approximation
conversion_key = "%s_%s" % (approx_type, conversion_type)
self.__table[orig_op_name][conversion_key]["time"] = total_time
self.__table[orig_op_name][conversion_key]["energy"] = total_energy
# Create a new row in the dictionary
else:
......@@ -147,50 +149,21 @@ class TableGenerator:
curr_op = [curr_line] # Join into a string later
operation_data = self.__table[curr_line]
h2f_data = [None] * 2
f2h_data = [None] * 2
has_h2f_field = False
has_f2h_field = False
# Iterate through time/energy data for each approx type
for approx_type in operation_data:
op_time = operation_data[approx_type]["time"]
op_energy = operation_data[approx_type]["energy"]
if approx_type == "h2f":
h2f_data[0] = op_time
h2f_data[1] = op_energy
has_h2f_field = True
elif approx_type == "f2h":
f2h_data[0] = op_time
f2h_data[1] = op_energy
has_f2h_field = True
else:
curr_op.append(op_time)
curr_op.append(op_energy)
# CRITICAL ASSUMPTION: All ops within a layer have the same # cols
# Only fill out the header once for the layer
if op_in_layer_count == 0:
header.append("%s_time" % approx_type)
header.append("%s_energy" % approx_type)
# Guarantee that the quantization data is at the end of the col
# TODO: How essential is this bc it increases the complexity of my code
if has_h2f_field:
curr_op.append(' '.join(h2f_data))
if has_f2h_field:
curr_op.append(' '.join(f2h_data))
ops_in_layer.append(' '.join(curr_op))
# can either just be the approx time or can be the approx type_h2f/f2h field
curr_op.append(op_time)
curr_op.append(op_energy)
# update header with h2f/f2h cols if they exist
if has_h2f_field:
header.append("h2f_time")
header.append("h2f_energy")
if has_f2h_field:
header.append("f2h_time")
header.append("f2h_energy")
# CRITICAL ASSUMPTION: All ops within a layer have the same # cols
# Only fill out the header once for the layer
if op_in_layer_count == 0:
header.append("%s_time" % approx_type)
header.append("%s_energy" % approx_type)
ops_in_layer.append(' '.join(curr_op))
# Getting all operation rows and then writing everything because
# calls to write() are slow (memory vs time tradeoff)
......
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