Skip to content

Commit 25df091

Browse files
author
chenfeiyu
committed
add an assertion to ensure that the size of each dim of the parameter to be created is larger than 0.
1 parent 0192b82 commit 25df091

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/paddle/fluid/layer_helper_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@ def create_parameter(self,
312312
if not attr:
313313
return None
314314
assert isinstance(attr, ParamAttr)
315+
for i, size in enumerate(shape):
316+
assert size > 0, (
317+
"Expected every dim's size to be larger than 0, "
318+
"but the size of the {}-th dim is {}".format(i, size))
315319
# set global dtype
316320
if not dtype:
317321
dtype = self.__dtype

0 commit comments

Comments
 (0)