diff options
author | Matthew Haddon <matthew.haddon@arm.com> | 2021-10-12 11:07:53 +0100 |
---|---|---|
committer | Matthew Haddon <matthew.haddon@arm.com> | 2021-10-12 16:24:45 +0100 |
commit | 718ef8ef9054b68e2a30738d4a2b13794276b1bc (patch) | |
tree | 2bcfd1526d02fbebf05e47f87bfb7b29a7fffd12 | |
parent | 7c2cdbcf6385729784b0ff26e96bd58604b80ab9 (diff) | |
download | specification-718ef8ef9054b68e2a30738d4a2b13794276b1bc.tar.gz |
refactor SLICE error_if checks
* refactored error_if checks to avoid logic overlap
* Added check to ensure that size dimensions match
output dimension
* Defined the rank() function in pseudocode helpers
Change-Id: I56bf06252d9149d449c984126e8f2025a07d6034
Signed-off-by: Matthew Haddon <matthew.haddon@arm.com>
-rw-r--r-- | chapters/data_layout.adoc | 9 | ||||
-rw-r--r-- | chapters/pseudocode.adoc | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc index bc8d853..773e949 100644 --- a/chapters/data_layout.adoc +++ b/chapters/data_layout.adoc @@ -201,14 +201,15 @@ No data conversion happens during a slice operation. [source,c++] ---- +ERROR_IF(rank(input1) != length(start) || rank(input1) != length(size)); +ERROR_IF(rank(input1) != rank(output)) // Sanity check the given coordinates, ensure start and end are // within tensor bounds for_each(index in rank(input1)) { - ERROR_IF(start[index] < 0 || - start[index] >= shape1[index]); - ERROR_IF(start[index] + size[index] < 0 || - start[index] + size[index] >= shape1[index]); + ERROR_IF(start[index] < 0); ERROR_IF(size[index] <= 0); //Output must be positive size + ERROR_IF(start[index] + size[index] > shape1[index]); + ERROR_IF(shape[index] != size[index]); } for_each(index in shape) { diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc index 5e6af5b..79ec190 100644 --- a/chapters/pseudocode.adoc +++ b/chapters/pseudocode.adoc @@ -151,4 +151,7 @@ int length(in_t input) int floor(in_t input) return input value rounded down to nearest integer + +int rank(in_t input) + return rank of an input tensor ----
\ No newline at end of file |