From 9a03fdff316662be69a1adc4e391e43bc6519b08 Mon Sep 17 00:00:00 2001 From: Charles Xu Date: Thu, 2 Jul 2020 15:12:40 +0200 Subject: MLBEDSW-2569:Support 1x1 IFM ResizeBilinear Signed-off-by: Charles Xu Change-Id: I44428d77b2e8e44a477e5c4dfe28ab8dd1792838 --- ethosu/vela/register_command_stream_generator.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ethosu/vela/register_command_stream_generator.py') diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py index d32766b0..38b40ba5 100644 --- a/ethosu/vela/register_command_stream_generator.py +++ b/ethosu/vela/register_command_stream_generator.py @@ -478,6 +478,11 @@ def generate_register_command_stream(nng, sg, arch, verbose=False): if (faf == "Sigmoid") or (faf == "Tanh"): output_scale = 1 / 0x3000 + # Force output scale same as the input scale for + # resizebiliner 1x1 that is converted to add + if "resizebilinear" in primary_op.attrs: + output_scale = input2_scale + if input_scale == input2_scale: opa_scale, opb_scale, ofm_scale, shift = scaling.simplified_elementwise_add_sub_scale( input_scale, input2_scale, output_scale @@ -860,7 +865,17 @@ def generate_register_command_stream(nng, sg, arch, verbose=False): emit.cmd0_with_param(zero_point_op, 0) else: assert tens.quantization.zero_point is not None, "need an actual zero point set" - emit.cmd0_with_param(zero_point_op, int(tens.quantization.zero_point)) + if ( + "resizebilinear" in primary_op.attrs + and primary_op.type == "AddAct" + and cmd0.NPU_SET_OFM_ZERO_POINT == zero_point_op + ): + # Force output zero point same as the input zero point + # for resizebiliner 1x1 that is converted to add + zero_point = cmd.ifm2_tensor.quantization.zero_point + else: + zero_point = tens.quantization.zero_point + emit.cmd0_with_param(zero_point_op, int(zero_point)) if tens.shape == []: # Empty shape, elementwise constant -- cgit v1.2.1