Kevin Petit | a7ac313 | 2024-01-08 15:27:25 +0000 | [diff] [blame] | 1 | // |
| 2 | // This confidential and proprietary software may be used only as |
| 3 | // authorised by a licensing agreement from ARM Limited |
| 4 | // (C) COPYRIGHT 2020-2024 ARM Limited |
| 5 | // ALL RIGHTS RESERVED |
| 6 | // The entire notice above must be reproduced on all authorised |
| 7 | // copies and copies may only be made to the extent permitted |
| 8 | // by a licensing agreement from ARM Limited. |
| 9 | |
| 10 | ERROR_IF(shape != broadcast_shape(shape1, shape2)); |
| 11 | for_each(index in shape) { |
Eric Kunze | 526f6c7 | 2024-01-12 17:18:42 -0800 | [diff] [blame^] | 12 | shape_t index1 = apply_broadcast(shape, shape1, index); |
| 13 | shape_t index2 = apply_broadcast(shape, shape2, index); |
Kevin Petit | a7ac313 | 2024-01-08 15:27:25 +0000 | [diff] [blame] | 14 | in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1); |
| 15 | in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2); |
| 16 | |
| 17 | // Ensure that shift amount is appropriate for the data type |
| 18 | REQUIRE((in_out_t == i32_t && 0 <= value2 && value2 <= 31) || |
| 19 | (in_out_t == i16_t && 0 <= value2 && value2 <= 15) || |
| 20 | (in_out_t == i8_t && 0 <= value2 && value2 <= 7)); |
| 21 | |
| 22 | in_out_t result = apply_arith_rshift<in_out_t>(value1, value2); |
| 23 | if (round == true && static_cast<int32_t>(value2) > 0 && |
Kevin Petit | 1c16f54 | 2024-01-16 21:40:08 +0000 | [diff] [blame] | 24 | (apply_arith_rshift<in_out_t>(value1, apply_sub_s<in_out_t>(value2, 1)) & 1 != 0)) { |
Kevin Petit | a7ac313 | 2024-01-08 15:27:25 +0000 | [diff] [blame] | 25 | result = result + 1; |
| 26 | } |
| 27 | result = apply_clip_s<in_out_t>(result, minimum_s<in_out_t>, maximum_s<in_out_t>); |
| 28 | tensor_write<in_out_t>(output, shape, index, result); |
| 29 | } |