MLBEDSW-2654: Convert Resizebilinear to a number of 2x2 pools
Signed-off-by: Charles Xu <charles.xu@arm.com>
Change-Id: Ida307afc33cd7963bdeb505df400732a3efcc846
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py
index 7b1e9a6..5a14cb4 100644
--- a/ethosu/vela/register_command_stream_generator.py
+++ b/ethosu/vela/register_command_stream_generator.py
@@ -666,6 +666,11 @@
ifm_scale_f64 = np.double(cmd.ifm_tensor.quantization.scale_f32)
ofm_scale_f64 = np.double(cmd.ofm_tensor.quantization.scale_f32)
scale, shift = scaling.quantise_scale(ifm_scale_f64 / ofm_scale_f64)
+ elif primary_op.type == "ResizeBilinear" and "rescale" in primary_op.attrs:
+ rescale = primary_op.attrs["rescale"]
+ rescale_bits = len(bin(round_up_to_int(rescale))) - 2 + 1
+ scale, shift = scaling.quantise_pooling_scale(k_height * k_width, rescale_bits)
+ scale = int(round_away_zero(scale * rescale))
else:
# In case avg pool fused with concat or other memory operation, rescaling might be needed.
# k_height == k_width == 1 is allways true in this case