未验证 提交 f2ec69b4 编写于 作者: G gouzil 提交者: GitHub

[Divide by 0 Error] add svd check (#49968)

* [Divide by 0 Error] add svd check

* [Divide by 0 Error] svd check migrate to c++, move svd test_0_size
上级 620ce8b8
......@@ -320,6 +320,16 @@ class TestSvdAPI(unittest.TestCase):
)
np.testing.assert_allclose(fetches[0], gt_s, rtol=1e-05)
def test_errors(self):
with paddle.fluid.dygraph.guard():
# The size of input in svd should not be 0.
def test_0_size():
array = np.array([], dtype=np.float32)
x = paddle.to_tensor(np.reshape(array, [0, 0]), dtype='float32')
paddle.linalg.svd(x, full_matrices=False)
self.assertRaises(ValueError, test_0_size)
if __name__ == "__main__":
paddle.enable_static()
......
......@@ -1921,6 +1921,7 @@ def svd(x, full_matrices=False, name=None):
# U * UH == I
# V * VH == I
"""
if in_dygraph_mode():
return _C_ops.svd(x, full_matrices)
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册