MLBEDSW-6879: TFLG pass-through test crash
- The optimisation of the SHAPE operator resulted in a divide by zero
when printing the percentage of npu/cpu operators in the final output
summary
- The fix is to detect when there are no operators in the output tflite
and then avoid the division
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: I5bd2342335e9468a8b7028e6e2291a03960e2e55
diff --git a/ethosu/vela/stats_writer.py b/ethosu/vela/stats_writer.py
index 22605a6..f3e2dba 100644
--- a/ethosu/vela/stats_writer.py
+++ b/ethosu/vela/stats_writer.py
@@ -277,7 +277,7 @@
n_cpu_operations = len(cpu_operations)
n_npu_operations = len(npu_operations)
- n_total_operations = n_cpu_operations + n_npu_operations
+ n_total_operations = max(n_cpu_operations + n_npu_operations, 1) # avoid potential divide by zero
def format_tens_list(lst):
return " ".join(str(list(tens.shape)) for tens in lst)