diff options
Diffstat (limited to 'chapters/tensor_ops.adoc')
-rw-r--r-- | chapters/tensor_ops.adoc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chapters/tensor_ops.adoc b/chapters/tensor_ops.adoc index 0b78c8f..ad4d75d 100644 --- a/chapters/tensor_ops.adoc +++ b/chapters/tensor_ops.adoc @@ -96,8 +96,11 @@ ERROR_IF(pad_top < 0 || pad_bottom < 0 || pad_left < 0 || pad_right < 0); // a divide-by-zero. ERROR_IF(pad_right >= kernel_x || pad_left >= kernel_x); ERROR_IF(pad_top >= kernel_y || pad_bottom >= kernel_y); +// Output shape must match expected shape given the input shape +// and arguments provided +ERROR_IF(H != floor((IH + pad_top + pad_bottom + stride_y - kernel_y) / stride_y)) +ERROR_IF(W != floor((IW + pad_left + pad_right + stride_x - kernel_x) / stride_x)) -pad = flatten([0,0], pad, [0,0]); for_each(0 <= n < N, 0 <= oy < H, 0 <= ox < W, 0 <= c < C ) { in_t output_val; acc_t acc = 0; @@ -428,6 +431,10 @@ ERROR_IF(pad_top < 0 || pad_bottom < 0 || pad_left < 0 || pad_right < 0); // input values will be used. ERROR_IF(pad_right >= kernel_x || pad_left >= kernel_x); ERROR_IF(pad_top >= kernel_y || pad_bottom >= kernel_y); +// Output shape must match expected shape given the input shape +// and arguments provided +ERROR_IF(H != floor((IH + pad_top + pad_bottom + stride_y - kernel_y) / stride_y)) +ERROR_IF(W != floor((IW + pad_left + pad_right + stride_x - kernel_x) / stride_x)) for_each(0 <= n < N, 0 <= oy < H, 0 <= ox < W, 0 <= c < C ) { in_t acc = minimum_value<in_t>; @@ -436,7 +443,6 @@ for_each(0 <= n < N, 0 <= oy < H, 0 <= ox < W, 0 <= c < C ) { for_each( 0 <= ky < kernel_y, 0 <= kx < kernel_x ) { y = iy + ky; x = ix + kx; - ERROR_IF(y >= IH + pad_bottom || x >= IW + pad_right); if (y >= 0 && y < IH && x >= 0 && x < IW) { in_t value = tensor_read<in_t>(input, [N,IH,IW,C], [n,y,x,c]); acc = apply_max(acc, value); |