提交 dbde51e6 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!5774 Add data type check

Merge pull request !5774 from lilei/add_check
......@@ -464,6 +464,10 @@ def initializer(init, shape=None, dtype=mstype.float32):
elif isinstance(shape, numbers.Number):
shape = (shape,)
for value in shape if shape is not None else ():
if not isinstance(value, int) or value <= 0:
raise ValueError(f"shape is invalid, shape value must be positive integer, shape:{shape}")
if isinstance(init, Initializer):
init.shape = init.shape if init.shape is not None else shape
init.dtype = init.dtype if init.dtype is not None else dtype
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册