diff options
author | Eric Kunze <eric.kunze@arm.com> | 2022-05-26 16:38:40 -0700 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2022-06-17 20:38:16 +0000 |
commit | f9e5ba94f12a71f088c790f532cd62d33b8d25d0 (patch) | |
tree | a9fd45db2d8931d5818cd3a7b422f706b224aeae /chapters/data_layout.adoc | |
parent | a177e435e4065f68b5c8c2cc3e84a2e4f7d1ecae (diff) | |
download | specification-f9e5ba94f12a71f088c790f532cd62d33b8d25d0.tar.gz |
Rework the introduction
The information on quantization and numerics was out of date.
The tensor access helpers were also consolidated and moved into
their own section in the pseudocode chapter.
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: I472e674ed88f4a3ef379010cf50b13cf8afa5f17
Diffstat (limited to 'chapters/data_layout.adoc')
-rw-r--r-- | chapters/data_layout.adoc | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc index 099a4c2..7bc2413 100644 --- a/chapters/data_layout.adoc +++ b/chapters/data_layout.adoc @@ -137,18 +137,10 @@ ERROR_IF(tensor_size(shape1) != tensor_size(shape)); for_each(index in shape) { // Calculate flattened index for the output location (index) - int32_t calculated_index = 0; - int32_t multiplier = 1; - for(r = rank(shape) - 1; r >= 0; r--) { - calculated_index += index[r] * multiplier; - multiplier *= shape[r]; - } + size_t offset = tensor_index_to_offset(shape, index); // Now convert to the location in the input - int32_t tmp_index[]; - for(r = rank(shape1) - 1; r >= 0; r--) { - tmp_index[r] = calculated_index % shape1[r]; - calculated_index /= shape1[r]; - } + dim_t tmp_index = tensor_offset_to_index(shape1, offset); + // Now read/write the value in_out_t val = tensor_read<in_out_t>(input, shape1, tmp_index); tensor_write<in_out_t>(output, shape, index, val); |