diff options
author | Eric Kunze <eric.kunze@arm.com> | 2021-03-08 16:17:26 -0800 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2021-03-11 10:20:06 -0800 |
commit | 8e4a9d33f0527107fda724fc0f7b6b7c1f42bf79 (patch) | |
tree | bdb67b880fcae88f08cf45c27fdd5e572df007d4 /chapters/type_conversion.adoc | |
parent | 1e9ba65f263a15f1f9cf9b9484047ea51237187a (diff) | |
download | specification-8e4a9d33f0527107fda724fc0f7b6b7c1f42bf79.tar.gz |
Adjust pseudocode types to account for zero point
When reading tensor values with zero point, the returned value
has one more bit than the original to account for zero point.
Update cases of apply_clip to properly represent the types
involved.
Change-Id: I60c17b1b244c34b4f04f042807936ae0f282ce93
Diffstat (limited to 'chapters/type_conversion.adoc')
-rw-r--r-- | chapters/type_conversion.adoc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/chapters/type_conversion.adoc b/chapters/type_conversion.adoc index 8f9e255..6701297 100644 --- a/chapters/type_conversion.adoc +++ b/chapters/type_conversion.adoc @@ -106,12 +106,12 @@ for_each(index in shape) { assert(in_t == int8_t || in_t == uint8_t || input_zp == 0); assert(out_t == int8_t || out_t == uint8_t || output_zp == 0); assert((scale32 && in_t != int48_t_t) || (!scale32 && !double_round)); - int48_t_t value = tensor_read<in_t>(input, shape, index, input_zp); + int48_t value = tensor_read<in_t>(input, shape, index, input_zp); int c = (per_channel) ? index[dims-1] : 0; int32_t result = (scale32) ? apply_scale_32(value, multiplier[c], shift[c], double_round) : apply_scale_16(value, multiplier[c], shift[c]); - result = apply_clip<out_t>(result + output_zp, minimum<out_t>, maximum<out_t>); + result = (out_t)apply_clip<int32_t>(result + output_zp, minimum<out_t>, maximum<out_t>); tensor_write<out_t>(output, shape, index, result); } .... |