From 7fb1f7a25f8c5940319f64d82c76a9baa91714b5 Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Thu, 23 Nov 2017 14:18:08 +0800 Subject: [PATCH] Fix lstm_op and gru_op in debug mode. --- paddle/operators/math/math_function.cu | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/paddle/operators/math/math_function.cu b/paddle/operators/math/math_function.cu index 58356a4b77..3018e50a4f 100644 --- a/paddle/operators/math/math_function.cu +++ b/paddle/operators/math/math_function.cu @@ -297,7 +297,25 @@ void set_constant_with_place( template struct RowwiseAdd; template struct RowwiseAdd; template struct ColwiseSum; -template struct ColwiseSum; +// template struct ColwiseSum; +// The ColwiseSum failed in debug mode, +// and only failed for this case. So reimplemented it. +template <> +void ColwiseSum::operator()( + const platform::DeviceContext& context, const framework::Tensor& input, + framework::Tensor* vector) { + auto in_dims = input.dims(); + auto size = input.numel() / in_dims[0]; + PADDLE_ENFORCE_EQ(vector->numel(), size); + framework::Tensor one; + one.mutable_data({in_dims[0]}, context.GetPlace()); + SetConstant set; + set(context, &one, static_cast(1.0)); + gemv(context, true, static_cast(in_dims[0]), + static_cast(in_dims[1]), 1.0, + input.data(), one.data(), + 0.0, vector->data()); +} } // namespace math } // namespace operators -- GitLab