diff options
author | Dominic Symes <dominic.symes@arm.com> | 2020-10-22 13:57:22 +0100 |
---|---|---|
committer | Dominic Symes <dominic.symes@arm.com> | 2020-10-27 09:03:02 +0000 |
commit | 3da62dfa0da290dbbb39e411ca2187703429f916 (patch) | |
tree | d756d462ee1c07cb23c8d31bd3738785ac77abb8 | |
parent | 298a029348e07903b1f78eb9994230fa205e869e (diff) | |
download | specification-3da62dfa0da290dbbb39e411ca2187703429f916.tar.gz |
ARITHMETIC_RIGHT_SHIFT: Add rounding
Add rounding mode to shift right and clarify
that shift values cannot be negative.
Signed-off-by: Dominic Symes <dominic.symes@arm.com>
Change-Id: I7995c8dfa6f16f9ca4dcbf5241692fcd940e509b
-rw-r--r-- | chapters/ewise_binary.adoc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc index 9c0e71c..4da63de 100644 --- a/chapters/ewise_binary.adoc +++ b/chapters/ewise_binary.adoc @@ -57,6 +57,7 @@ Elementwise arithmetic right shift of input1 by the amount specified in input2. |Input|in_t*|input1|shape1|Input tensor |Input|in_t*|input2|shape2|Input tensor with the same rank as input1 +|Input|bool |round |- | If true then the shift is rounded |Output|in_t*|output|shape|Output tensor with broadcast shape if necessary |=== @@ -69,8 +70,11 @@ for_each (index in shape) { index2 = apply_broadcast(shape, shape2, index) in_t value1 = tensor_read<in_t>(input1, shape1, index1) in_t value2 = tensor_read<in_t>(input2, shape2, index2) - assert(value2 <= 31) + assert(0 <= value2 && value2 <= 31) in_t acc = value1 >> value2 + if (round==true && value2>0 && (value1>>(value2-1))&1!=0) { + acc = acc + 1; + } acc = apply_clip(acc, minimum<in_t>, maximum<in_t>) tensor_write<in_t>(output, shape, index, acc) } @@ -263,7 +267,7 @@ for_each (index in shape) { index2 = apply_broadcast(shape, shape2, index) in_t value1 = tensor_read<in_t>(input1, shape1, index1) in_t value2 = tensor_read<in_t>(input2, shape2, index2) - assert(value2 <= 31) + assert(0 <= value2 && value2 <= 31) in_t acc = value1 << value2 tensor_write<in_t>(output, shape, index, acc) } @@ -302,7 +306,7 @@ for_each (index in shape) { index2 = apply_broadcast(shape, shape2, index) in_t value1 = tensor_read<in_t>(input1, shape1, index1) in_t value2 = tensor_read<in_t>(input2, shape2, index2) - assert(value2 <= 31) + assert(0 <= value2 && value2 <= 31) in_t acc = (unsigned in_t)value1 >> value2 tensor_write<in_t>(output, shape, index, acc) } |