From dbe8122031c9205068dff853606dc3d7d69bac8c Mon Sep 17 00:00:00 2001
From: Elizabeth <hashim.sharif91@gmail.com>
Date: Tue, 8 Oct 2019 17:51:46 -0500
Subject: [PATCH] Added time/energy labels for headers and fixed quantization
 data to be at the end

---
 .../build_pldi/table_generator.py             | 52 +++++++++++++++----
 1 file changed, 43 insertions(+), 9 deletions(-)

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 ff0f9b37c0..e6c4298f30 100644
--- a/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
+++ b/llvm/projects/hpvm-tensor-rt/build_pldi/table_generator.py
@@ -139,7 +139,7 @@ class TableGenerator:
             
             # Get each operation in the layer
             ops_in_layer = []
-            header = ["**", layer_name, str(num_ops), "_"]
+            header = ["**", layer_name, str(num_ops)]
             
             for op_in_layer_count in range(num_ops): 
                 # Each line consists of operation name  
@@ -147,17 +147,51 @@ 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:
-                    curr_op.append(operation_data[approx_type]["time"]) 
-                    curr_op.append(operation_data[approx_type]["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(approx_type)    
-               
+                    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))
+
+            # 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")
+
             # Getting all operation rows and then writing everything because
             # calls to write() are slow (memory vs time tradeoff)
             print("%s" % ' '.join(header))
-- 
GitLab