未验证 提交 23b9ed34 编写于 作者: F Feiyu Chan 提交者: GitHub

add an assertion to ensure that the size of each dim of the parameter to be...

add an assertion to ensure that the size of each dim of the parameter to be created is larger than 0. (#33265)
上级 3bbf2d7e
...@@ -312,6 +312,10 @@ class LayerHelperBase(object): ...@@ -312,6 +312,10 @@ class LayerHelperBase(object):
if not attr: if not attr:
return None return None
assert isinstance(attr, ParamAttr) 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 # set global dtype
if not dtype: if not dtype:
dtype = self.__dtype dtype = self.__dtype
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册