aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--chapters/comparison.adoc1
-rw-r--r--chapters/data_layout.adoc13
-rw-r--r--chapters/pseudocode.adoc3
3 files changed, 15 insertions, 2 deletions
diff --git a/chapters/comparison.adoc b/chapters/comparison.adoc
index 3d7ae05..43f0787 100644
--- a/chapters/comparison.adoc
+++ b/chapters/comparison.adoc
@@ -54,6 +54,7 @@ Elementwise greater than comparison operation
|===
|Argument|Type|Name|Shape|Description
+
|Input|in_t*|input1|shape1|Input tensor
|Input|in_t*|input2|shape2|Input tensor with the same rank as input1
|Output|out_t*|output|shape|Output tensor with broadcast shape if necessary
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];
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc
index 79ec190..16e7e67 100644
--- a/chapters/pseudocode.adoc
+++ b/chapters/pseudocode.adoc
@@ -154,4 +154,7 @@ int floor(in_t input)
int rank(in_t input)
return rank of an input tensor
+
+int sum(in_t input[])
+ return the sum of values of an input list
---- \ No newline at end of file