From 3170439f3938d007e58998d61eed98560c3f026c Mon Sep 17 00:00:00 2001
From: Eric Kunze <eric.kunze@arm.com>
Date: Mon, 25 Oct 2021 16:04:20 -0700
Subject: Remove zp subtraction from tensor_read pseudocode

Operators which use the zero-point functionalty for 8-bit integer
processing are updated to do the zero-point subtract in their
pseudocode.

Note that the PAD operator no longer takes a zero point argument,
and instead requires callers to account for the zero point in the
pad_const argument.

Change-Id: I3bca1cae85aa2093000c420f0433633c347a29de
---
 chapters/ewise_unary.adoc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'chapters/ewise_unary.adoc')

diff --git a/chapters/ewise_unary.adoc b/chapters/ewise_unary.adoc
index 2dc01df..e2b754a 100644
--- a/chapters/ewise_unary.adoc
+++ b/chapters/ewise_unary.adoc
@@ -247,10 +247,11 @@ Elementwise negation operation
 ERROR_IF(in_t != int8_t && input1_zp != 0) // Zero point only for int8_t
 ERROR_IF(in_t != int8_t && output_zp != 0) // Zero point only for int8_t
 for_each(index in shape) {
-    acc_t acc = tensor_read<in_t>(input1, shape, index, input1_zp);
-    acc = apply_sub<acc_t>(0, acc);
-    in_t value = (in_t)apply_clip<acc_t>(acc + output_zp, minimum<in_t>, maximum<in_t>);
-    tensor_write<in_t>(output, shape, index, value);
+    in_t value1 = tensor_read<in_t>(input1, shape, index);
+    acc_t value = (acc_t)value1 - input1_zp;
+    value = apply_sub<acc_t>(0, value);
+    in_t result = (in_t)apply_clip<acc_t>(value + output_zp, minimum<in_t>, maximum<in_t>);
+    tensor_write<in_t>(output, shape, index, result);
 }
 ----
 
-- 
cgit v1.2.1

