Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaTrainingG committed Jul 15, 2021
1 parent 0b20b76 commit f621651
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions paddle/fluid/operators/pool_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,12 @@ limitations under the License. */
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/pooling.h"
#if defined(__HIPCC__) || defined(__NVCC__)
#include "paddle/fluid/operators/reduce_ops/cub_reduce.h"
#include "paddle/fluid/operators/reduce_ops/reduce_functor_op.h"
#include "paddle/fluid/operators/reduce_ops/reduce_op.cu.h"
#endif

namespace paddle {
namespace operators {
template <typename T>
struct DivideFunctor {
HOSTDEVICE explicit inline DivideFunctor(int n) : n_inv((T)(1.0 / n)) {}

template <typename U>
HOSTDEVICE inline U operator()(const U& x) const {
return x * static_cast<U>(n_inv);
}

private:
T n_inv;
};

using Tensor = framework::Tensor;

Expand Down Expand Up @@ -219,9 +208,7 @@ class PoolKernel : public framework::OpKernel<T> {
adaptive) { // for adaptive_avg_pool2d && output_size == 1
#if defined(__HIPCC__) || defined(__NVCC__)
auto stream = dev_ctx.stream();
TensorReduce<T, T, cub::Sum, DivideFunctor<T>>(
*in_x, out, reduce_dim, static_cast<T>(0), cub::Sum(),
DivideFunctor<T>(reduce_num), stream);
TensorReduceFunc<T, T, CustomMean>(*in_x, out, reduce_dim, stream);
#else // for cpu
paddle::operators::math::Pool2dFunctor<
DeviceContext, paddle::operators::math::AvgPool<T>, T>
Expand Down

0 comments on commit f621651

Please sign in to comment.