aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Symes <dominic.symes@arm.com>2021-06-11 10:49:51 +0100
committerDominic Symes <dominic.symes@arm.com>2021-06-17 09:46:38 +0000
commitf19e594f71e04c72ecf937419333b57dc7dcb873 (patch)
tree4561ef37461afe04a3fea6897714cc54debf05ce
parent7a2e08cdb14fd198a6f15468e24dd98791990df8 (diff)
downloadspecification-f19e594f71e04c72ecf937419333b57dc7dcb873.tar.gz
RESIZE: Clarify dimension limits
X and Y dimensions of image limited to 16-bit for integer data types so that the position * stride calculations do not overflow an int32_t (both position and stride are then 16-bit) Signed-off-by: Dominic Symes <dominic.symes@arm.com> Change-Id: I24d15b1f2991a18da15493bef478d5ee9c65dba3
-rw-r--r--chapters/image.adoc28
1 files changed, 18 insertions, 10 deletions
diff --git a/chapters/image.adoc b/chapters/image.adoc
index b560b5c..3bf4109 100644
--- a/chapters/image.adoc
+++ b/chapters/image.adoc
@@ -53,16 +53,24 @@ None
[source,c++]
----
-// shift assert prevents int32_t accumulator overflow for in_t==int8_t
-assert((resize_t == float_t && shift == 0)||(0 < shift && shift <= 11));
-// stride asserts set consistent lower limit of 1/16 downscale
-// independent of the shift value to simplify implementations
-assert(0 < stride_x && stride_x < (16 << shift));
-assert(0 < stride_y && stride_y < (16 << shift));
-// offset range is similarly limited to maximum 16 pixels irrespective
-// of shift. Both stride and offset fit in int16_t when shift=11.
-assert((-16 << shift) < offset_x && offset_x < (16 << shift));
-assert((-16 << shift) < offset_y && offset_y < (16 << shift));
+// Ensure image size is supported by GPU APIs and that for integer
+// implementations, position * stride does not overflow int32_t.
+assert(max(OH,OW,IH,IW) < 16384);
+if (resize_t == float_t) {
+ // The shift attribute is not used for floating point
+ assert(shift == 0);
+} else {
+ // if in_t=int8_t ensure that an int32_t accumulator can be used
+ assert(0 < shift && shift <= 11);
+ // set a consistent lower limit of 1/16 downscale
+ // independent of the shift value to simplify implementations
+ assert(0 < stride_x && stride_x < (16 << shift));
+ assert(0 < stride_y && stride_y < (16 << shift));
+ // offset range is similarly limited to maximum 16 pixels irrespective
+ // of shift. Both stride and offset fit in int16_t when shift=11.
+ assert((-16 << shift) < offset_x && offset_x < (16 << shift));
+ assert((-16 << shift) < offset_y && offset_y < (16 << shift));
+}
for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= c < C) {
unit = (resize_t == float_t) ? 1.0 : (1 << shift);
y = oy * stride_y + offset_y;