From 14cfb8c262c1f16c8916087c8dc4ce2d16500c7e Mon Sep 17 00:00:00 2001 From: qijun Date: Wed, 19 Jul 2017 08:22:21 +0000 Subject: [PATCH] fix gpu build error --- cmake/flags.cmake | 1 + paddle/operators/mul_op.h | 7 ++++--- paddle/operators/rowwise_add_op.h | 1 + paddle/operators/softmax_op.h | 21 ++++++++++++--------- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cmake/flags.cmake b/cmake/flags.cmake index c31e62fc08..34fd348893 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -124,6 +124,7 @@ set(GPU_COMMON_FLAGS -Wno-error=literal-suffix -Wno-error=unused-local-typedefs -Wno-error=unused-function # Warnings in Numpy Header. + -Wno-error=array-bounds # Warnings in Eigen::array ) if (APPLE) diff --git a/paddle/operators/mul_op.h b/paddle/operators/mul_op.h index 13e5b6a950..81d5953cf0 100644 --- a/paddle/operators/mul_op.h +++ b/paddle/operators/mul_op.h @@ -24,9 +24,10 @@ template class MulKernel : public framework::OpKernel { public: void Compute(const framework::KernelContext& context) const override { - Eigen::array, 1> dim_pair; - dim_pair[0].first = 1; - dim_pair[0].second = 0; + Eigen::array, 1> dim_pair = { + Eigen::IndexPair(1, 0)}; + // dim_pair[0].first = 1; + // dim_pair[0].second = 0; auto input0 = context.Input(0)->Get(); auto input1 = context.Input(1)->Get(); diff --git a/paddle/operators/rowwise_add_op.h b/paddle/operators/rowwise_add_op.h index f1d43002dc..dd5cde0c5d 100644 --- a/paddle/operators/rowwise_add_op.h +++ b/paddle/operators/rowwise_add_op.h @@ -26,6 +26,7 @@ public: auto in0 = context.Input(0)->Get(); auto in1 = context.Input(1)->Get(); auto* out = context.Output(0)->GetMutable(); + out->mutable_data(context.GetPlace()); auto input = in0.matrix(); auto bias = in1.vec(); diff --git a/paddle/operators/softmax_op.h b/paddle/operators/softmax_op.h index 34a6c299bb..6d675ea5f6 100644 --- a/paddle/operators/softmax_op.h +++ b/paddle/operators/softmax_op.h @@ -26,6 +26,7 @@ public: void Compute(const framework::KernelContext& context) const override { auto input = context.Input(0)->Get(); auto* output = context.Output(0)->GetMutable(); + output->mutable_data(context.GetPlace()); auto logits = input.matrix(); auto softmax = output->matrix(); @@ -40,19 +41,21 @@ public: Eigen::DSizes batch_by_one(batch_size, 1); Eigen::DSizes one_by_class(1, num_classes); - auto shifted_logits = (logits - logits.maximum(along_class) - .eval() - .reshape(batch_by_one) - .broadcast(one_by_class)); + auto shifted_logits = (logits - + logits.maximum(along_class) + .eval() + .reshape(batch_by_one) + .broadcast(one_by_class)); softmax.device(*(context.GetEigenDevice())) = shifted_logits.exp(); softmax.device(*(context.GetEigenDevice())) = - (softmax * softmax.sum(along_class) - .inverse() - .eval() - .reshape(batch_by_one) - .broadcast(one_by_class)); + (softmax * + softmax.sum(along_class) + .inverse() + .eval() + .reshape(batch_by_one) + .broadcast(one_by_class)); } }; } // namespace operators -- GitLab