From 36e5de81817e1a20e0a8b8b4d98e36ff92321c3f 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: Tue, 7 Feb 2023 20:04:52 +0800 Subject: [PATCH] fix div 0 error in chunk (#49998) --- python/paddle/fluid/tests/unittests/test_chunk_op.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/paddle/fluid/tests/unittests/test_chunk_op.py b/python/paddle/fluid/tests/unittests/test_chunk_op.py index 71244097276..f6bc1e4f03b 100644 --- a/python/paddle/fluid/tests/unittests/test_chunk_op.py +++ b/python/paddle/fluid/tests/unittests/test_chunk_op.py @@ -52,6 +52,14 @@ class TestChunkOpError(unittest.TestCase): self.assertRaises(TypeError, test_axis_type_tensor) + with paddle.fluid.dygraph.guard(): + + def test_0_chunks_tensor(): + x = paddle.uniform([1, 1, 1], dtype='float32') + paddle.chunk(x, chunks=0) + + self.assertRaises(ValueError, test_0_chunks_tensor) + class API_TestChunk(unittest.TestCase): def test_out(self): -- GitLab