diff options
-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 |