diff options
Diffstat (limited to 'chapters')
-rw-r--r-- | chapters/data_layout.adoc | 30 | ||||
-rw-r--r-- | chapters/data_nodes.adoc | 6 |
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:* |