aboutsummaryrefslogtreecommitdiff
path: root/chapters/data_layout.adoc
diff options
context:
space:
mode:
authorMatthew Haddon <matthew.haddon@arm.com>2021-10-13 13:38:47 +0100
committerMatthew Haddon <matthew.haddon@arm.com>2021-10-15 13:49:19 +0100
commit7c5f53273c20bbae0232b57451aa060ff1e96dbc (patch)
tree4d9c84170c614f82549a3689d1bfe399ac0c71e2 /chapters/data_layout.adoc
parent718ef8ef9054b68e2a30738d4a2b13794276b1bc (diff)
downloadspecification-7c5f53273c20bbae0232b57451aa060ff1e96dbc.tar.gz
Add ERROR_IF checks to CONCAT operator
* Add ERROR_IF checks to ensure that inputs have the correct rank, dimension lengths, and a suitable axis value * Make REVERSE REQUIRES check into an ERROR_IF * Some minor typo/formatting fixes Change-Id: Ie133788ca7e1deab194ba5ef97e47c39cdd170b6 Signed-off-by: Matthew Haddon <matthew.haddon@arm.com>
Diffstat (limited to 'chapters/data_layout.adoc')
-rw-r--r--chapters/data_layout.adoc13
1 files changed, 11 insertions, 2 deletions
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc
index 773e949..1c87d4b 100644
--- a/chapters/data_layout.adoc
+++ b/chapters/data_layout.adoc
@@ -18,7 +18,7 @@ No data conversion happens during a concat operation.
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t**|input1|shapes1[]|List of input tensors. All inputs must have the same rank
+|Input|in_t*|input1|shapes1[]|List of input tensors. All inputs must have the same rank and data type
|Attribute|int|axis|-|Axis along which concatenation is to occur, in range from 0 to rank(shape)-1
|Output|in_t*|output|shape|Output tensor
|===
@@ -27,6 +27,15 @@ No data conversion happens during a concat operation.
[source,c]
----
+ERROR_IF(axis < 0 || axis >= rank(shapes1[0]));
+ERROR_IF(shape[axis] != sum(shape1[k][axis] for all k))
+// The following checks ensure all inputs are compatible for concatenation
+for_each(input_shape in shapes1) {
+ ERROR_IF(rank(input_shape) != rank(shapes1[0]));
+ for_each(index in input_shape) {
+ ERROR_IF(input_shape[index] != shapes1[0][index] && index != axis);
+ }
+}
for_each(index1 in shape) {
index2 = index1;
for (tensor t = 0; t < length(input1); t++) {
@@ -161,7 +170,7 @@ Returns a tensor with the same type/values as the input, with the data reversed
[source,c++]
----
-REQUIRE(0 <= axis && axis < rank(shape));
+ERROR_IF(axis < 0 || axis >= rank(shape));
for_each(index in shape) {
tmp_index = index;
tmp_index[axis] = shape[axis] - 1 - index[axis];