aboutsummaryrefslogtreecommitdiff
path: root/chapters/image.adoc
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2023-07-18 15:20:53 -0700
committerEric Kunze <eric.kunze@arm.com>2023-08-17 09:32:28 -0700
commitfb0284e2912bd5fd73bf6f476901490e04c330a2 (patch)
tree1784e40ad84a91e751679a4cbdf6cd33be1eefdb /chapters/image.adoc
parentb5b067819e5de11153b41cf3d26da4f3f9dd23e8 (diff)
downloadspecification-fb0284e2912bd5fd73bf6f476901490e04c330a2.tar.gz
Change TOSA specification to signless types
Integer inputs and outputs to TOSA operators are now defined as signless values. In most instances the operator will used signed arithmetic as indicated in previous versions of the specification resulting in little functional change to the specification. New attributes have been added to the RESCALE operator to indicate whether the input and output values should be treated as signed or unsigned. Explicit use of static_cast, sign_extend, zero_extend and truncate are added to the pseudocode to avoid ambiguity. Change-Id: I71c67d3e5aeaabc418c768f821fce6ee3eebb65b
Diffstat (limited to 'chapters/image.adoc')
-rw-r--r--chapters/image.adoc23
1 files changed, 12 insertions, 11 deletions
diff --git a/chapters/image.adoc b/chapters/image.adoc
index 8abc878..da839f8 100644
--- a/chapters/image.adoc
+++ b/chapters/image.adoc
@@ -1,7 +1,7 @@
//
// This confidential and proprietary software may be used only as
// authorised by a licensing agreement from ARM Limited
-// (C) COPYRIGHT 2020-2021 ARM Limited
+// (C) COPYRIGHT 2020-2023 ARM Limited
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorised
// copies and copies may only be made to the extent permitted
@@ -91,22 +91,23 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= c < C) {
int16_t rx = x - ix * scale_x_n; // (x % scale_x_n)
if (is_floating_point(resize_t)) {
- dy = (resize_t)ry / (resize_t)scale_y_n;
- dx = (resize_t)rx / (resize_t)scale_x_n;
+ dy = static_cast<resize_t>(ry) / static_cast<resize_t>(scale_y_n);
+ dx = static_cast<resize_t>(rx) / static_cast<resize_t>(scale_x_n);
} else {
dy = ry;
dx = rx;
}
// Note that -1 <= iy < IH and -1 <= ix < IW
- int16_t iy0 = apply_max(iy, 0);
- int16_t iy1 = apply_min(iy + 1, IH - 1);
- int16_t ix0 = apply_max(ix, 0);
- int16_t ix1 = apply_min(ix + 1, IW - 1);
+ int16_t iy0 = apply_max_s(iy, 0);
+ int16_t iy1 = apply_min_s(iy + 1, IH - 1);
+ int16_t ix0 = apply_max_s(ix, 0);
+ int16_t ix1 = apply_min_s(ix + 1, IW - 1);
if (mode==BILINEAR) {
- in_t v00 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix0,c]);
- in_t v01 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix1,c]);
- in_t v10 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix0,c]);
- in_t v11 = tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix1,c]);
+ using in_s_t = make_signed(in_t); // Use signed calculations for i8/i16
+ in_s_t v00 = static_cast<in_s_t>(tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix0,c]));
+ in_s_t v01 = static_cast<in_s_t>(tensor_read<in_t>(input, [N,IH,IW,C], [n,iy0,ix1,c]));
+ in_s_t v10 = static_cast<in_s_t>(tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix0,c]));
+ in_s_t v11 = static_cast<in_s_t>(tensor_read<in_t>(input, [N,IH,IW,C], [n,iy1,ix1,c]));
acc = v00 * (unit_y - dy) * (unit_x - dx);
acc += v01 * (unit_y - dy) * dx;
acc += v10 * dy * (unit_x - dx);