Skip to content

Commit

Permalink
Add new api: paddle.prod
Browse files Browse the repository at this point in the history
test=develop
  • Loading branch information
gfwm2013 committed Aug 17, 2020
1 parent 0b0fcda commit 5123131
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/paddle/fluid/tests/unittests/test_prod_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run_static(self, use_gpu=False):
result4 = paddle.prod(input, axis=1, dtype='int64')
result5 = paddle.prod(input, axis=1, keepdim=True, dtype='int64')

place = fluid.CUDAPlace(0) if use_gpu else fluid.CPUPlace()
place = fluid.CUDAPlace(4) if use_gpu else fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(fluid.default_startup_program())
static_result = exe.run(
Expand Down Expand Up @@ -93,7 +93,7 @@ def test_gpu(self):
if not fluid.core.is_compiled_with_cuda():
return

paddle.disable_static(place=paddle.fluid.CUDAPlace(6))
paddle.disable_static(place=paddle.fluid.CUDAPlace(4))
self.run_imperative()
paddle.enable_static()

Expand All @@ -107,13 +107,16 @@ def test_error(self):
x = paddle.data(name='x', shape=[2, 2, 4], dtype='float32')
bool_x = paddle.data(name='bool_x', shape=[2, 2, 4], dtype='bool')
# The argument x shoule be a Tensor
#self.assertRaises(AssertionError, paddle.prod, [1])
self.assertRaises(TypeError, paddle.prod, [1])

# The data type of x should be float32, float64, int32, int64
self.assertRaises(TypeError, paddle.prod, bool_x)

# The argument axis's type shoule be int ,list or tuple
self.assertRaises(TypeError, paddle.prod, x, 1.5)

# The argument dtype of prod_op should be float32, float64, int32 or int64.
self.assertRaises(TypeError, paddle.randn, x, 'int32')
self.assertRaises(TypeError, paddle.prod, x, 'bool')


if __name__ == "__main__":
Expand Down

0 comments on commit 5123131

Please sign in to comment.