aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Symes <dominic.symes@arm.com>2020-10-09 12:00:41 +0100
committerDominic Symes <dominic.symes@arm.com>2020-10-12 16:58:55 +0000
commit56b56724c1e20db875a11979cd2903bd58bd9087 (patch)
tree34dfa4bccb9be4eb6ee65674af92c107abc6936e
parentedbb7ba7504c13ea3fad8ee4e822bf451c8b8240 (diff)
downloadspecification-56b56724c1e20db875a11979cd2903bd58bd9087.tar.gz
Fix errors in RESIZE
Fix typing errors in the resize operation and simplify the assert checking. Signed-off-by: Dominic Symes <dominic.symes@arm.com> Change-Id: If12b9e54a6e9f84f0d6122be7d4a4b567fd81e0f
-rw-r--r--chapters/image.adoc14
1 files changed, 7 insertions, 7 deletions
diff --git a/chapters/image.adoc b/chapters/image.adoc
index 1e8974c..c3cd390 100644
--- a/chapters/image.adoc
+++ b/chapters/image.adoc
@@ -36,32 +36,32 @@ None
[source,c]
----
assert(0<shift && shift<=11); // prevent int32_t accumulator overflow for in_t==int8_t
-assert(-stride_y < offset_y && offset_y < (IH<<shift)-(OH-1)*stride_y)
-assert(-stride_x < offset_x && offset_x < (IH<<shift)-(OW-1)*stride_x)
+assert(stride_x>0 && stride_y>0);
for_each (0<=n<N, 0<=oy<OH, 0<=ox<OW; 0<=c<C) {
y = oy * stride_y + offset_y
x = ox * stride_x + offset_x
iy = y >> shift; dy = y - (iy<<shift);
ix = x >> shift; dx = x - (ix<<shift);
iy0 = apply_max(iy,0);
- iy1 = apply_mix(iy,IW-1);
+ iy1 = apply_min(iy+1,IH-1);
ix0 = apply_max(ix,0);
- ix1 = apply_min(ix,IH-1);
+ ix1 = apply_min(ix+1,IW-1);
+ assert(ix0<=ix1 && iy0<=iy1);
if (mode==BILINEAR) {
v00 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix0,c])
v01 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix1,c])
v10 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix0,c])
v11 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix1,c])
- acc_t acc = v00*((1<<shift)-dy)*((1<<shift)-dx)
+ out_t acc = v00*((1<<shift)-dy)*((1<<shift)-dx)
acc = acc + v01*((1<<shift)-dy)*dx
acc = acc + v10*dy*((1<<shift)-dx)
acc = acc + v11*dy*dx
- tensor_write<acc_t>(output, [N,OH,OW,C], [n,oy,ox,c], acc)
+ tensor_write<out_t>(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;
v = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy,ix,c]);
- tensor_write<acc_t>(output, [N,OH,OW,C], [n,oy,ox,c], v)
+ tensor_write<out_t>(output, [N,OH,OW,C], [n,oy,ox,c], v)
}
}
----