From 48ab823ec4c9d454e31283d24ae18347a8abc54f Mon Sep 17 00:00:00 2001 From: RedContritio Date: Sun, 22 Jan 2023 17:00:40 +0000 Subject: [PATCH] add stride check for PoolOutputSize --- paddle/phi/kernels/funcs/pooling.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/paddle/phi/kernels/funcs/pooling.h b/paddle/phi/kernels/funcs/pooling.h index c0741672a458e1..f1656c8a177a73 100644 --- a/paddle/phi/kernels/funcs/pooling.h +++ b/paddle/phi/kernels/funcs/pooling.h @@ -371,6 +371,13 @@ inline int PoolOutputSize(int input_size, int padding_2, int stride, bool ceil_mode) { + PADDLE_ENFORCE_NE( + stride, + 0, + phi::errors::InvalidArgument( + "The stride of PoolOutputSize shall not be 0, but received %d.", + stride)); + int output_size; if (!ceil_mode) { output_size =