From 6361d1664c7b82ecc3afdd0eb87e96afea430f89 Mon Sep 17 00:00:00 2001 From: Dominic Symes Date: Mon, 15 Aug 2022 10:50:57 +0100 Subject: PAD: Check output shape Check output shape matches the padded input shape. Signed-off-by: Dominic Symes Change-Id: I8e335ce9b086a36d9e38aa332ecc88782e040cc6 --- chapters/data_layout.adoc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc index 0c5c4d6..5ba9012 100644 --- a/chapters/data_layout.adoc +++ b/chapters/data_layout.adoc @@ -78,7 +78,7 @@ The pad_const value includes the zero point if the tensor uses a zero point. |Argument|Type|Name|Shape|Description |Input|in_out_t*|input1|shape1|Input tensor -|Attribute|int32_t|padding|[rank(input1),2]|Amount of padding to be done +|Attribute|int32_t|padding|[rank(shape1),2]|Number of pad elements at the start and end of each dimension |Attribute|in_out_t|pad_const|-|Constant value to be used as padding |Output|in_out_t*|output|shape|Output tensor of same type as the input tensor |=== @@ -87,9 +87,11 @@ The pad_const value includes the zero point if the tensor uses a zero point. [source,c++] ---- -// Padding sizes must be >= 0. -for_each(pad_size in padding) { - ERROR_IF(pad_size < 0); +// Check output shape matches the padded input shape +ERROR_IF(rank(shape) != rank(shape1)); +for (i = 0; i < rank(shape); i++) { + ERROR_IF(padding[i,0] < 0 || padding[i,1] < 0); + ERROR_IF(shape[i] != padding[i, 0] + shape1[i] + padding[i, 1]); } for_each(index in shape) { index1 = index; -- cgit v1.2.1