From b4f52b01d0383a4aa8f7597029a926cf074a07a3 Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Sat, 18 Aug 2018 00:27:45 +0800 Subject: [PATCH] bug fix when all inputs are empty --- paddle/fluid/operators/sum_mkldnn_op.cc | 3 +++ paddle/fluid/operators/sum_op.h | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/sum_mkldnn_op.cc b/paddle/fluid/operators/sum_mkldnn_op.cc index 148366a72ac..f9a16ef35ec 100644 --- a/paddle/fluid/operators/sum_mkldnn_op.cc +++ b/paddle/fluid/operators/sum_mkldnn_op.cc @@ -187,6 +187,9 @@ class SumMKLDNNOpKernel : public paddle::framework::OpKernel { if (in_dim.empty()) { VLOG(3) << "WARNING: all the inputs are empty"; + in_dim = framework::vectorize(get_selected_row(N - 1).value().dims()); + } else { + in_dim[0] = static_cast(first_dim); } in_dim[0] = static_cast(first_dim); diff --git a/paddle/fluid/operators/sum_op.h b/paddle/fluid/operators/sum_op.h index f1d885b7fd6..6dffe527c10 100644 --- a/paddle/fluid/operators/sum_op.h +++ b/paddle/fluid/operators/sum_op.h @@ -116,10 +116,11 @@ class SumKernel : public framework::OpKernel { } if (in_dim.empty()) { VLOG(3) << "WARNING: all the inputs are empty"; + in_dim = framework::vectorize(get_selected_row(N - 1).value().dims()); + } else { + in_dim[0] = static_cast(first_dim); } - in_dim[0] = static_cast(first_dim); - out_value->Resize(framework::make_ddim(in_dim)); out_value->mutable_data(context.GetPlace()); -- GitLab