From f097419bd742646adefd5ac2280bd00783da0481 Mon Sep 17 00:00:00 2001 From: Dominic Symes Date: Thu, 22 Oct 2020 11:29:09 +0100 Subject: RESIZE: Add float type Add floating point as an allowed data type for RESIZE. Signed-off-by: Dominic Symes Change-Id: I01766edabe922d395175356387ea325bfc301fd3 --- chapters/image.adoc | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/chapters/image.adoc b/chapters/image.adoc index c3cd390..f1b3a92 100644 --- a/chapters/image.adoc +++ b/chapters/image.adoc @@ -20,9 +20,9 @@ Resizes a tensor. Resize is only allowed in the H and W dimensions. In expected |Input|in_t*|input|[N,IH,IW,C]|Input tensor |Attribute|int*|output_size|[2]|[OH,OW] -|Attribute|int16*|stride|[2]|[stride_y, stride_x] -|Attribute|int16*|offset|[2]|[offset_y, offset_x] -|Attribute|int|shift|Shift value +|Attribute|scale_t*|stride|[2]|[stride_y, stride_x] +|Attribute|scale_t*|offset|[2]|[offset_y, offset_x] +|Attribute|int|shift|Shift value (must be zero if scale_t is float) |Attribute|mode_t|mode|-|BILINEAR or NEAREST |Output|out_t*|output|[N,OH,OW,C]|Output tensor |=== @@ -35,13 +35,20 @@ None [source,c] ---- -assert(00 && stride_y>0); for_each (0<=n> shift; dy = y - (iy<> shift; dx = x - (ix<> shift; dy = y - (iy<> shift; dx = x - (ix<(input, [N,IH,IW,C], [n,iy0,ix1,c]) v10 = tensor_read(input, [N,IH,IW,C], [n,iy1,ix0,c]) v11 = tensor_read(input, [N,IH,IW,C], [n,iy1,ix1,c]) - out_t acc = v00*((1<(output, [N,OH,OW,C], [n,oy,ox,c], acc) } else if (mode==NEAREST) { - iy = (dy>>(shift-1))!=0 ? iy1 : iy0; - ix = (dx>>(shift-1))!=0 ? ix1 : ix0; + iy = (dy >= unit/2) ? iy1 : iy0; + ix = (dx >= unit/2) ? ix1 : ix0; v = tensor_read(input, [N,IH,IW,C], [n,iy,ix,c]); tensor_write(output, [N,OH,OW,C], [n,oy,ox,c], v) } @@ -69,12 +74,13 @@ for_each (0<=n