aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/register_command_stream_generator.py
diff options
context:
space:
mode:
authorDwight Lidman <dwight.lidman@arm.com>2020-04-30 11:54:48 +0200
committerTim Hall <tim.hall@arm.com>2020-06-18 17:53:52 +0100
commit3ec04ac9e38d26193e0081a8e0fa3b8b667bb688 (patch)
treed4c961583bbe7ff47a9a0313d72ff0871a44b72d /ethosu/vela/register_command_stream_generator.py
parent1629f331810de8ebff018259c75ee024857472e5 (diff)
downloadethos-u-vela-3ec04ac9e38d26193e0081a8e0fa3b8b667bb688.tar.gz
MLBEDSW-1498: Add Resize_Bilinear operator support
This patch adds support for the ResizeBilinear operator. It is implemented using a 2x2 Nearest Neighbor upscale followed by a 2x2 Average Pool. Depending on the argument align_corners the output is either of shape: - (2 * M, 2 * N) when align_corners == True, or - (2 * M - 1, 2 * N - 1) when align_corners == False where (M, N) is the input shape. The padding mode is SAME when align_corners == True and VALID when align_corners == False. The argument half_pixel_centers is out of scope and is as of now ignored. Note that only upscaling by a factor of 2 is supported. Change-Id: Ia6d6d010c4f1bb13f5f839bc8d16872a626d9a3b Signed-off-by: Dwight Lidman <dwight.lidman@arm.com>
Diffstat (limited to 'ethosu/vela/register_command_stream_generator.py')
-rw-r--r--ethosu/vela/register_command_stream_generator.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ethosu/vela/register_command_stream_generator.py b/ethosu/vela/register_command_stream_generator.py
index 460cf016..7a4faa80 100644
--- a/ethosu/vela/register_command_stream_generator.py
+++ b/ethosu/vela/register_command_stream_generator.py
@@ -401,6 +401,8 @@ def generate_register_command_stream(nng, sg, arch, verbose=False):
use_global_scale = False
# Specifies type of rounding to be used.
rounding_mode = rounding.TFL
+ if primary_op.type == 'ResizeBilinear':
+ rounding_mode = rounding.TRUNCATE
fmf = primary_op.attrs.get("fused_memory_function", None)
faf = primary_op.attrs.get("fused_activation_function", None)
@@ -537,7 +539,11 @@ def generate_register_command_stream(nng, sg, arch, verbose=False):
emit.cmd0_with_param(cmd0.NPU_SET_ACC_FORMAT, acc_format_map[shared_buffer.use_accumulator_element])
- emit.cmd0_with_param(cmd0.NPU_SET_IFM_UPSCALE, 0)
+ if primary_op.type == 'ResizeBilinear':
+ # perform nearest neighbor upscale
+ emit.cmd0_with_param(cmd0.NPU_SET_IFM_UPSCALE, 1)
+ else:
+ emit.cmd0_with_param(cmd0.NPU_SET_IFM_UPSCALE, 0)
if npu_block_type in set(
(NpuBlockType.ConvolutionMxN, NpuBlockType.ConvolutionDepthWise, NpuBlockType.Pooling)
@@ -579,7 +585,7 @@ def generate_register_command_stream(nng, sg, arch, verbose=False):
valid_padding = sum(explicit_padding) == 0
- if primary_op.type in set(("AvgPool", "AvgPoolAct")) and valid_padding:
+ if primary_op.type in set(("AvgPool", "AvgPoolAct", "ResizeBilinear")) and valid_padding:
# For valid padding vela has to output scaling values
if faf == "Sigmoid" or faf == "Tanh":
rescale = 0x3000 * cmd.ifm_tensor.quantization.scale_f32