diff --git a/python/paddle/fluid/tests/unittests/test_histogram_op.py b/python/paddle/fluid/tests/unittests/test_histogram_op.py index 71283aceaa4030cc79751677dba9fd98dc680d3a..dc52df4226a29733def185d9afa080a115191aac 100644 --- a/python/paddle/fluid/tests/unittests/test_histogram_op.py +++ b/python/paddle/fluid/tests/unittests/test_histogram_op.py @@ -153,6 +153,14 @@ class TestHistogramOp(OpTest): self.check_output(check_eager=True) +class TestHistogramOp_ZeroDim(TestHistogramOp): + def init_test_case(self): + self.in_shape = [] + self.bins = 5 + self.min = 1 + self.max = 5 + + if __name__ == "__main__": paddle.enable_static() unittest.main() diff --git a/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py b/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py index cc7a257e4c4726cbbdfdadc4af90c653a8724ac9..a97d28412029f3e8d341cd539e0a5e986affc05f 100755 --- a/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py +++ b/python/paddle/fluid/tests/unittests/test_zero_dim_tensor.py @@ -917,6 +917,11 @@ class TestSundryAPI(unittest.TestCase): self.assertEqual(out.grad.shape, [1]) self.assertEqual(x.grad.shape, []) + def test_histogram(self): + x = paddle.rand([]) + out = paddle.histogram(x, bins=5, min=1, max=5) + self.assertEqual(out.shape, [5]) + def test_scale(self): x = paddle.rand([]) x.stop_gradient = False @@ -1658,6 +1663,16 @@ class TestSundryAPIStatic(unittest.TestCase): self.assertEqual(res[1].shape, ()) self.assertEqual(res[2].shape, (1,)) + @prog_scope() + def test_histogram(self): + x = paddle.full([], 1, 'float32') + out = paddle.histogram(x, bins=5, min=1, max=5) + + prog = paddle.static.default_main_program() + res = self.exe.run(prog, feed={}, fetch_list=[out]) + + self.assertEqual(res[0].shape, (5,)) + @prog_scope() def test_scale(self): x = paddle.rand([])