From 23b9ed342729947b42bdd7069e174e166778bc40 Mon Sep 17 00:00:00 2001 From: Feiyu Chan Date: Thu, 3 Jun 2021 10:37:47 +0800 Subject: [PATCH] add an assertion to ensure that the size of each dim of the parameter to be created is larger than 0. (#33265) --- python/paddle/fluid/layer_helper_base.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/paddle/fluid/layer_helper_base.py b/python/paddle/fluid/layer_helper_base.py index e9738b6660e..c2de5670eb4 100644 --- a/python/paddle/fluid/layer_helper_base.py +++ b/python/paddle/fluid/layer_helper_base.py @@ -312,6 +312,10 @@ class LayerHelperBase(object): if not attr: return None assert isinstance(attr, ParamAttr) + for i, size in enumerate(shape): + assert size > 0, ( + "Expected every dim's size to be larger than 0, " + "but the size of the {}-th dim is {}".format(i, size)) # set global dtype if not dtype: dtype = self.__dtype -- GitLab