From f9267da3ad6251a7e04f501218380ac9a89953b7 Mon Sep 17 00:00:00 2001 From: Tim Hall Date: Wed, 20 Apr 2022 20:19:48 +0100 Subject: MLBEDSW-6407: Vela fails with TypeError in npu_performance - This is due to calling range() on a non-integer value which in turn is due to a change in the behaviour of round() on numpy.float64 values - The fix is to always force the output of the round() to be an integer and thereby stop whole number floating point values propagating into the kernel dimensions which later feed into the range(). Signed-off-by: Tim Hall Change-Id: Ic75cb6ba85a90c81c1d762067d89a10caaa13b92 --- ethosu/vela/tflite_graph_optimiser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ethosu/vela/tflite_graph_optimiser.py b/ethosu/vela/tflite_graph_optimiser.py index 88d58a32..b2a34195 100644 --- a/ethosu/vela/tflite_graph_optimiser.py +++ b/ethosu/vela/tflite_graph_optimiser.py @@ -318,7 +318,9 @@ def convert_resizebilinear_to_nearest_neighbor_upscaling_and_pool(op): out_shape = np.array(op.ofm_shapes[0].get_hw_as_list()) # Calculate how many times 2x2 upscaling needs to be performed - upscale_factor = round(out_shape[1] / upscaled_shape[1]) + # Force the result of round to be an integer. This is because the behaviour of rounding numpy.float64 values changed + # between different versions of numpy. This consistency ensures that the kernel dimensions are kept integral + upscale_factor = int(round(out_shape[1] / upscaled_shape[1])) n = int(np.log2(upscale_factor)) # Perform 2x2 upscaling n-1 times -- cgit v1.2.1