diff options
author | Eric Kunze <eric.kunze@arm.com> | 2020-12-15 15:41:05 -0800 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2020-12-16 14:25:20 -0800 |
commit | e5d22a77300643f0a3013ad40ccd2b5b76788b42 (patch) | |
tree | 61ccb85014ce007166882c79c690ceae1534f289 /chapters/introduction.adoc | |
parent | 5d60c71300ecb78cd59ca30f6383ec7f5527d3c5 (diff) | |
download | specification-e5d22a77300643f0a3013ad40ccd2b5b76788b42.tar.gz |
Disambiguate scale_t in RESIZE command
scale_t is already defined globally for the rescaling.
Move pseudocode for count_leading_zeros to introduction,
and use it in the implementation of CLZ.
Change-Id: I2453bce93b6dd25e870b8a010fc62af4c001cbf9
Diffstat (limited to 'chapters/introduction.adoc')
-rw-r--r-- | chapters/introduction.adoc | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc index 3133f36..da1c1b1 100644 --- a/chapters/introduction.adoc +++ b/chapters/introduction.adoc @@ -330,8 +330,9 @@ acc_t apply_sub<acc_t>(acc_t a, acc_t b) { } .... -The following functions are used in the pseudocode to take maximum, minimum or clip values to a range. - +The following functions are used in the pseudocode to take maximum, +minimum, clip values to a range, or count leading zeros. +[[count_leading_zeros]] .... <type> apply_max<type>(<type> a, <type> b) { if (a >= b) return a; else return b; @@ -347,6 +348,20 @@ The following functions are used in the pseudocode to take maximum, minimum or c value = apply_min(value, max_val); return value; } + +int32_t count_leading_zeros(int32_t a) { + int32_t acc = 32; + if (a != 0) { + uint32_t mask; + mask = 1 << (32 - 1); // width of int32_t - 1 + acc = 0; + while ((mask & a) == 0) { + mask = mask >> 1; + acc = acc + 1; + } + } + return acc; +} .... ==== Quantized Convolutions |