diff options
Diffstat (limited to 'pseudocode/operators/FULLY_CONNECTED.tosac')
-rw-r--r-- | pseudocode/operators/FULLY_CONNECTED.tosac | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pseudocode/operators/FULLY_CONNECTED.tosac b/pseudocode/operators/FULLY_CONNECTED.tosac new file mode 100644 index 0000000..fbacccc --- /dev/null +++ b/pseudocode/operators/FULLY_CONNECTED.tosac @@ -0,0 +1,25 @@ +// +// This confidential and proprietary software may be used only as +// authorised by a licensing agreement from ARM Limited +// (C) COPYRIGHT 2020-2024 ARM Limited +// ALL RIGHTS RESERVED +// The entire notice above must be reproduced on all authorised +// copies and copies may only be made to the extent permitted +// by a licensing agreement from ARM Limited. + +ERROR_IF(in_t != i8_t && input_zp != 0); // Zero point only for int8_t +ERROR_IF(weight_t != i8_t && weight_zp != 0); +ERROR_IF(BC != OC && BC != 1); + +for_each(0 <= n < N, 0 <= oc < OC) { + out_t acc = 0; + for_each(0 <= ic < IC) { + out_t value = static_cast<out_t>(tensor_read<in_t>(input, [N,IC], [n,ic])); + out_t weight = static_cast<out_t>(tensor_read<weight_t>(weight, [OC,IC], [oc,ic])); + value = apply_sub_s<out_t>(value, static_cast<out_t>(input_zp)); + weight = apply_sub_s<out_t>(weight, static_cast<out_t>(weight_zp)); + acc = apply_add_s<out_t>(acc, apply_mul_s<out_t>(value, weight)); + } + acc = apply_add_s<out_t>(acc, bias[(BC == 1) ? 0 : oc]); + tensor_write<out_t>(output, [N,OC], [n,oc], acc); +} |