diff --git a/paddle/operators/reduce_op.cc b/paddle/operators/reduce_op.cc index 09b7091358e65221374a604122b742d763cfbafc..4a06babeda00f2420df80f81f876a0047a3285ef 100644 --- a/paddle/operators/reduce_op.cc +++ b/paddle/operators/reduce_op.cc @@ -190,10 +190,22 @@ REGISTER_OP(reduce_min, ops::ReduceOp, ops::ReduceMinOpMaker, reduce_min_grad, #define REGISTER_REDUCE_CPU_KERNEL(reduce_type, functor, grad_functor) \ REGISTER_OP_CPU_KERNEL(reduce_type, \ ops::ReduceKernel); \ + float, ops::functor>, \ + ops::ReduceKernel, \ + ops::ReduceKernel, \ + ops::ReduceKernel); \ REGISTER_OP_CPU_KERNEL( \ reduce_type##_grad, \ ops::ReduceGradKernel, \ + ops::ReduceGradKernel, \ + ops::ReduceGradKernel, \ + ops::ReduceGradKernel); FOR_EACH_KERNEL_FUNCTOR(REGISTER_REDUCE_CPU_KERNEL); diff --git a/paddle/operators/reduce_op.cu b/paddle/operators/reduce_op.cu index 1dd948ed8a79cce8468f2fe210b5636e7dd1f99e..4ed1e051db4df579afe1c1ca24a06fa1baf3e13a 100644 --- a/paddle/operators/reduce_op.cu +++ b/paddle/operators/reduce_op.cu @@ -20,10 +20,22 @@ namespace ops = paddle::operators; #define REGISTER_REDUCE_GPU_KERNEL(reduce_type, functor, grad_functor) \ REGISTER_OP_CUDA_KERNEL( \ reduce_type, ops::ReduceKernel); \ + float, ops::functor>, \ + ops::ReduceKernel, \ + ops::ReduceKernel, \ + ops::ReduceKernel); \ REGISTER_OP_CUDA_KERNEL( \ reduce_type##_grad, \ ops::ReduceGradKernel, \ + ops::ReduceGradKernel, \ + ops::ReduceGradKernel, \ + ops::ReduceGradKernel); FOR_EACH_KERNEL_FUNCTOR(REGISTER_REDUCE_GPU_KERNEL); diff --git a/python/paddle/v2/fluid/tests/test_reduce_op.py b/python/paddle/v2/fluid/tests/test_reduce_op.py index 57ee307ba66b47bd15864e7be3943b4f5237eb1e..e2df0395ea9c99ed6d74d582dc9822780dd9ee1d 100644 --- a/python/paddle/v2/fluid/tests/test_reduce_op.py +++ b/python/paddle/v2/fluid/tests/test_reduce_op.py @@ -19,7 +19,7 @@ from op_test import OpTest class TestSumOp(OpTest): def setUp(self): self.op_type = "reduce_sum" - self.inputs = {'X': np.random.random((5, 6, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 10)).astype("float64")} self.outputs = {'Out': self.inputs['X'].sum(axis=0)} def test_check_output(self): @@ -32,7 +32,7 @@ class TestSumOp(OpTest): class TestMeanOp(OpTest): def setUp(self): self.op_type = "reduce_mean" - self.inputs = {'X': np.random.random((5, 6, 2, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 2, 10)).astype("float64")} self.attrs = {'dim': 1} self.outputs = {'Out': self.inputs['X'].mean(axis=self.attrs['dim'])} @@ -48,7 +48,7 @@ class TestMaxOp(OpTest): def setUp(self): self.op_type = "reduce_max" - self.inputs = {'X': np.random.random((5, 6, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 10)).astype("float64")} self.attrs = {'dim': -1} self.outputs = {'Out': self.inputs['X'].max(axis=self.attrs['dim'])} @@ -61,7 +61,7 @@ class TestMinOp(OpTest): def setUp(self): self.op_type = "reduce_min" - self.inputs = {'X': np.random.random((5, 6, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 10)).astype("float64")} self.attrs = {'dim': 2} self.outputs = {'Out': self.inputs['X'].min(axis=self.attrs['dim'])} @@ -72,7 +72,7 @@ class TestMinOp(OpTest): class TestKeepDimReduce(OpTest): def setUp(self): self.op_type = "reduce_sum" - self.inputs = {'X': np.random.random((5, 6, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 10)).astype("float64")} self.attrs = {'dim': -2, 'keep_dim': True} self.outputs = { 'Out': self.inputs['X'].sum(axis=self.attrs['dim'], keepdims=True) @@ -88,7 +88,7 @@ class TestKeepDimReduce(OpTest): class Test1DReduce(OpTest): def setUp(self): self.op_type = "reduce_sum" - self.inputs = {'X': np.random.random(20).astype("float32")} + self.inputs = {'X': np.random.random(20).astype("float64")} self.outputs = {'Out': self.inputs['X'].sum(axis=0)} def test_check_output(self): @@ -101,7 +101,7 @@ class Test1DReduce(OpTest): class TestReduceAll(OpTest): def setUp(self): self.op_type = "reduce_sum" - self.inputs = {'X': np.random.random((5, 6, 2, 10)).astype("float32")} + self.inputs = {'X': np.random.random((5, 6, 2, 10)).astype("float64")} self.attrs = {'reduce_all': True} self.outputs = {'Out': self.inputs['X'].sum()}