Repository: larq/larq

Issue:
MAC output strings are wrong
In the table, but not in the summary, we are incorrectly dividing by `8 * 1024` and displaying a count in 'kB'.


Discussion:

Resolving patch:
diff --git a/larq/models.py b/larq/models.py
--- a/larq/models.py
+++ b/larq/models.py
@@ -282,10 +282,7 @@ def _generate_table_header(self, table_config):
                 for i in table_config["param_bidtwidths"]
             ),
             f"Memory\n({_bitsize_as_str(table_config['memory_units'])})",
-            *(
-                f"{i}-bit MACs\n({_bitsize_as_str(table_config['mac_units'])})"
-                for i in table_config["mac_precisions"]
-            ),
+            *(f"{i}-bit MACs" for i in table_config["mac_precisions"]),
         ]
 
     def _generate_table_total(self, table_config):
@@ -307,7 +304,7 @@ def generate_table(self, include_macs=True):
             "mac_precisions": self.unique_op_precisions if include_macs else [],
             "param_units": 1,
             "memory_units": 8 * 1024,
-            "mac_units": 8 * 1024,
+            "mac_units": 1,
         }
 
         table = []


Test patch:
diff --git a/larq/snapshots/snap_models_test.py b/larq/snapshots/snap_models_test.py
--- a/larq/snapshots/snap_models_test.py
+++ b/larq/snapshots/snap_models_test.py
@@ -9,16 +9,16 @@
 
 snapshots['test_summary 1'] = '''+sequential stats----------------------------------------------------------------------------------------------------------------+
 | Layer                   Input prec.           Outputs  # 1-bit  # 2-bit  # 32-bit  Memory  1-bit MACs  2-bit MACs  32-bit MACs |
-|                               (bit)                        x 1      x 1       x 1    (kB)        (kB)        (kB)         (kB) |
+|                               (bit)                        x 1      x 1       x 1    (kB)                                      |
 +--------------------------------------------------------------------------------------------------------------------------------+
-| quant_conv2d                      -  (-1, 64, 64, 32)      288        0        32    0.16           0           0       144.00 |
+| quant_conv2d                      -  (-1, 64, 64, 32)      288        0        32    0.16           0           0      1179648 |
 | max_pooling2d                     -  (-1, 32, 32, 32)        0        0         0       0           0           0            0 |
-| quant_depthwise_conv2d            2  (-1, 11, 11, 32)        0      288         0    0.07           0        4.25            0 |
-| quant_separable_conv2d            1  (-1, 11, 11, 32)     1312        0        32    0.29       19.38           0            0 |
+| quant_depthwise_conv2d            2  (-1, 11, 11, 32)        0      288         0    0.07           0       34848            0 |
+| quant_separable_conv2d            1  (-1, 11, 11, 32)     1312        0        32    0.29      158752           0            0 |
 | flatten                           -        (-1, 3872)        0        0         0       0           0           0            0 |
-| dense                             -          (-1, 10)        0        0     38730  151.29           0           0         4.73 |
+| dense                             -          (-1, 10)        0        0     38730  151.29           0           0        38720 |
 +--------------------------------------------------------------------------------------------------------------------------------+
-| Total                                                     1600      288     38794  151.80       19.38        4.25       148.73 |
+| Total                                                     1600      288     38794  151.80      158752       34848      1218368 |
 +--------------------------------------------------------------------------------------------------------------------------------+
 +sequential summary--------------------------+
 | Total params                       40.7 k  |