diff options
Diffstat (limited to 'chapters/ewise_binary.adoc')
-rw-r--r-- | chapters/ewise_binary.adoc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc index 2b1eadd..1a54a99 100644 --- a/chapters/ewise_binary.adoc +++ b/chapters/ewise_binary.adoc @@ -58,7 +58,7 @@ Axis of size 1 will be broadcast, as necessary. Rank of input tensors must match |Input|in_t*|input1|shape1|Input tensor |Input|in_t*|input2|shape2|Input tensor with the same rank as input1 -|Input|bool_t |round |- | If true then the shift is rounded +|Input|bool_t|round|-|If true then the shift is rounded |Output|in_t*|output|shape|Output tensor with broadcast shape if necessary |=== @@ -71,7 +71,12 @@ 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); - REQUIRE(0 <= value2 && value2 <= 31); + + // Ensure that shift amount is appropriate for the data type + REQUIRE((in_t == int32_t && 0 <= value2 && value2 <= 31) || + (in_t == int16_t && 0 <= value2 && value2 <= 15) || + (in_t == int8_t && 0 <= value2 && value2 <= 7)); + in_t acc = value1 >> value2; if (round == true && value2 > 0 && (value1 >> (value2 - 1)) & 1 != 0) { acc = acc + 1; |