diff options
author | Kevin Petit <kevin.petit@arm.com> | 2024-01-31 10:24:14 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2024-02-06 21:31:27 +0000 |
commit | c65cd9ccff6000be01ee0742319009f0061879ce (patch) | |
tree | 726ac4d8e85ad8e46e5240ff0f026eb99589dbd5 /pseudocode/library/apply_broadcast.tosac | |
parent | 6bf50e8706a6969e6a25be6b2638e81ad21489e7 (diff) | |
download | specification-c65cd9ccff6000be01ee0742319009f0061879ce.tar.gz |
pseudocode: move all helpers to separate files
Change-Id: I75ea94d42c63e862af8e492da7f47ecd6caa1055
Signed-off-by: Kevin Petit <kevin.petit@arm.com>
Diffstat (limited to 'pseudocode/library/apply_broadcast.tosac')
-rw-r--r-- | pseudocode/library/apply_broadcast.tosac | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pseudocode/library/apply_broadcast.tosac b/pseudocode/library/apply_broadcast.tosac new file mode 100644 index 0000000..4a86a42 --- /dev/null +++ b/pseudocode/library/apply_broadcast.tosac @@ -0,0 +1,24 @@ +// +// 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. + +// The index argument should be a valid location within out_shape. +// The function returns the location within in_shape that contributes +// to the output based on broadcasting rules. + +shape_t apply_broadcast(shape_t out_shape, shape_t in_shape, shape_t index) { + ERROR_IF(rank(out_shape) != rank(in_shape)); + ERROR_IF(rank(out_shape) != rank(index)); + for (int32_t i = 0; i < rank(out_shape); i++) { + if (out_shape[i] != in_shape[i]) { + ERROR_IF(in_shape[i] != 1); + index[i] = 0; + } + } + return index; +} |