aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2022-01-04 11:20:44 -0800
committerEric Kunze <eric.kunze@arm.com>2022-01-07 14:28:36 -0800
commit2a3d560999c794e8faacefa93db23bf1e1714532 (patch)
treec95da3b68ba11b937252ee3031a8a0413d10fb03
parenta3eded0843874a78e69e4b985cb2a492bfab78f3 (diff)
downloadspecification-2a3d560999c794e8faacefa93db23bf1e1714532.tar.gz
Ensure ranks match in apply_broadcast
ERROR_IF to make sure rank(index) == rank(out_shape) Also try to better explain what the expected value for index is. Change-Id: I0731324d33335cb1ffc0a6fbd153fbc8521ce2e9 Signed-off-by: Eric Kunze <eric.kunze@arm.com>
-rw-r--r--chapters/introduction.adoc5
1 files changed, 5 insertions, 0 deletions
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc
index 3fb5476..51d085d 100644
--- a/chapters/introduction.adoc
+++ b/chapters/introduction.adoc
@@ -304,8 +304,13 @@ The following function maps an index in the output tensor to an index in the inp
[source,c++]
----
+// 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.
+
dim_t apply_broadcast(dim_t out_shape, dim_t in_shape, dim_t index) {
ERROR_IF(rank(out_shape) != rank(in_shape));
+ ERROR_IF(rank(out_shape) != rank(index));
for (i = 0; i < rank(out_shape); i++) {
if (out_shape[i] != in_shape[i]) {
ERROR_IF(in_shape[i] != 1);