aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Kunze <eric.kunze@arm.com>2021-02-22 13:21:05 -0800
committerEric Kunze <eric.kunze@arm.com>2021-03-03 14:45:13 -0800
commit54ff87d31637c97958ac49e40312e9b6de0a8f1a (patch)
tree3fb67a5830882eb4d3e2f885df1c5604042caa1d
parent70b140f0219464a239bb40e53023d7de02eb71cc (diff)
downloadspecification-54ff87d31637c97958ac49e40312e9b6de0a8f1a.tar.gz
Change CONCAT to allow a list of input tensors
Originally only a pair of input tensors were allowed. This aligns with what the frameworks do, and simplifies the translation of frameworks into TOSA and allows compilers to view the output as a whole. Change-Id: Id4461abdf0cc763e84e086142222e87d28cd8afc Signed-off-by: Eric Kunze <eric.kunze@arm.com>
-rw-r--r--chapters/data_layout.adoc30
-rw-r--r--chapters/data_nodes.adoc6
2 files changed, 21 insertions, 15 deletions
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc
index 5d54e62..9d01e71 100644
--- a/chapters/data_layout.adoc
+++ b/chapters/data_layout.adoc
@@ -10,31 +10,37 @@
=== Data Layout
==== CONCAT
-Concatenate two tensors along a given axis. No data conversion happens during a concat operation.
+Concatenate a list of tensors along a given axis.
+No data conversion happens during a concat operation.
*Arguments:*
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t*|input1|shape1|Input tensor with rank from 1 to 4
-|Input|in_t*|input2|shape2|Input tensor with rank matching input1
-|Attribute|int|axis|-|Axis along which concatenation is to occur.
-|Output|in_t*|output|shape|Output tensor of same type, size as the input tensor
+|Input|in_t**|input1|shapes1[]|List of input tensors
+|Attribute|int|axis|-|Axis along which concatenation is to occur
+|Output|in_t*|output|shape|Output tensor
|===
*Operation Function:*
[source,c]
----
-for_each (index1 in shape) {
- index2 = index1
- index2[axis] = index1[axis] - shape1[axis]
- in_t value = (index2[axis] < 0) ?
- tensor_read<in_t>(input1, shape1, index1) :
- tensor_read<in_t>(input2, shape2, index2) ;
- tensor_write<in_t>(output, shape, index1, value);
+for_each(index1 in shape) {
+ index2 = index1;
+ for (tensor t = 0; t < length(input1); t++) {
+ // Continue to concatenate along axis from each tensor
+ // For each output location, we are looking for the
+ // appropriate input tensor
+ if (index2[axis] >= 0 && index2[axis] < shapes1[t][axis]) {
+ in_t value = tensor_read<in_t>(input1[t], shapes1[t], index2);
+ tensor_write<in_t>(output, shape, index1, value);
+ }
+ index2[axis] = index2[axis] - shapes1[t][axis];
+ }
}
+
----
*Supported Data Types:*
diff --git a/chapters/data_nodes.adoc b/chapters/data_nodes.adoc
index 4297a9a..87b0b9b 100644
--- a/chapters/data_nodes.adoc
+++ b/chapters/data_nodes.adoc
@@ -43,7 +43,7 @@ Returns a tensor with the same shape, type, and contents as the input.
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t|input1|shape|Input tensor
+|Input|in_t*|input1|shape|Input tensor
|Output|in_t*|output|shape|Output tensor of same type, size as the input tensor
|===
@@ -68,8 +68,8 @@ Returns a list of tensors with the same shape, type, and contents as the input l
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t|input1|[shape1, shape2, …]|List of input tensors
-|Output|in_t*|output|[shape1, shape2, …]|List of output tensors of same type, size as the input tensors
+|Input|in_t**|input1|shape[]|List of input tensors
+|Output|in_t**|output|shape[]|List of output tensors of same type, size as the input tensors
|===
*Supported Data Types:*