From 776021c10278d5e3e714237943022e8118fad526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=98=A5=E4=B9=94?= <83450930+Liyulingyue@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:34:42 +0800 Subject: [PATCH] fix the NullPointerError of matrix_power (#50015) --- python/paddle/fluid/tests/unittests/test_matrix_power_op.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_matrix_power_op.py b/python/paddle/fluid/tests/unittests/test_matrix_power_op.py index 6381aeeca9868..8296aa320f59b 100644 --- a/python/paddle/fluid/tests/unittests/test_matrix_power_op.py +++ b/python/paddle/fluid/tests/unittests/test_matrix_power_op.py @@ -317,6 +317,12 @@ def test_errors(self): input = fluid.data(name="input_4", shape=[1, 1, 0, 0], dtype="float32") self.assertRaises(ValueError, paddle.linalg.matrix_power, input, 2) + # The size of input should not be 0 + input = fluid.data(name="input_5", shape=[0, 0], dtype="float32") + self.assertRaises( + ValueError, paddle.linalg.matrix_power, input, -956301312 + ) + class TestMatrixPowerSingularAPI(unittest.TestCase): def setUp(self):