vela: Protect against divide by zero

If the total cycle count is zero (for whatever reason), then a divide by
zero can occur when calculating the midpoint_fps.
This change protects against that by detecting when that is the case and
instead setting the midpoint_fps to nan.
Further calculations using that variable is safe and results in nan
throughout.

Change-Id: I2d29545d331a6eb5b27b6d9c931587c15f877e74
Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com>
diff --git a/ethosu/vela/stats_writer.py b/ethosu/vela/stats_writer.py
index c90d987..af7b699 100644
--- a/ethosu/vela/stats_writer.py
+++ b/ethosu/vela/stats_writer.py
@@ -85,7 +85,10 @@
             )
 
         midpoint_inference_time = nng.cycles[PassCycles.Total] / arch.npu_clock
-        midpoint_fps = 1 / midpoint_inference_time
+        if midpoint_inference_time > 0:
+            midpoint_fps = 1 / midpoint_inference_time
+        else:
+            midpoint_fps = np.nan
 
         n_passes = sum(len(sg.passes) for sg in nng.subgraphs)
         n_cascaded_passes = sum(len(sg.cascaded_passes) for sg in nng.subgraphs)
@@ -231,7 +234,10 @@
     orig_mem_areas_labels = [(v, v.display_name()) for v in MemArea.all()]
 
     midpoint_inference_time = cycles[PassCycles.Total] / arch.npu_clock
-    midpoint_fps = 1 / midpoint_inference_time
+    if midpoint_inference_time > 0:
+        midpoint_fps = 1 / midpoint_inference_time
+    else:
+        midpoint_fps = np.nan
 
     mem_area_labels = [
         (mem_area, label) for mem_area, label in orig_mem_areas_labels if np.sum(bandwidths[mem_area]) > 0