From 2351845edee37537018f0a23c3b428ed84abab01 Mon Sep 17 00:00:00 2001 From: yangzhenzhang <285824651@qq.com> Date: Wed, 1 Jul 2020 15:24:17 +0800 Subject: [PATCH] delete shape validation in initializer --- mindspore/common/initializer.py | 4 ---- tests/ut/python/utils/test_initializer_fuzz.py | 9 +-------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/mindspore/common/initializer.py b/mindspore/common/initializer.py index 83586272ee..48a142a23f 100644 --- a/mindspore/common/initializer.py +++ b/mindspore/common/initializer.py @@ -343,10 +343,6 @@ def initializer(init, shape=None, dtype=mstype.float32): shape = tuple(shape) elif isinstance(shape, numbers.Number): shape = (shape,) - try: - np.ndarray(shape) - except ValueError: - raise ValueError("Error shape={}".format(shape)) if isinstance(init, Initializer): init.shape = init.shape if init.shape is not None else shape diff --git a/tests/ut/python/utils/test_initializer_fuzz.py b/tests/ut/python/utils/test_initializer_fuzz.py index 3a6fb4833f..5cd76a1cd8 100644 --- a/tests/ut/python/utils/test_initializer_fuzz.py +++ b/tests/ut/python/utils/test_initializer_fuzz.py @@ -49,13 +49,6 @@ class Net(nn.Cell): return out -def test_shape_error(): - """ for fuzz test""" - in_str = "3 22222222222222222222222222264 3 64 64 222 222 3" - with pytest.raises(ValueError): - Net(in_str) - - class LeNet5(nn.Cell): """ LeNet5 definition """ @@ -98,7 +91,7 @@ class LeNet5(nn.Cell): return x -def test_shape_error_2(): +def test_shape_error(): """ for fuzz test""" in_str = "3 6 5 6 -6 5 16 5 5 120 120 84 84 3 2" with pytest.raises(ValueError):