From c4c8f60bec0f22132369de182673bf0bce3ef29e Mon Sep 17 00:00:00 2001 From: tangwei12 Date: Tue, 31 Jul 2018 16:46:41 +0800 Subject: [PATCH] sum_op selectedRows dim bug fix --- paddle/fluid/operators/sum_op.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/sum_op.h b/paddle/fluid/operators/sum_op.h index 49a4afb3a8..a497c91289 100644 --- a/paddle/fluid/operators/sum_op.h +++ b/paddle/fluid/operators/sum_op.h @@ -105,8 +105,15 @@ class SumKernel : public framework::OpKernel { auto &sel_row = get_selected_row(i); first_dim += sel_row.rows().size(); } - auto in_dim = - framework::vectorize(get_selected_row(N - 1).value().dims()); + + std::vector in_dim; + for (int i = 0; i < N; i++) { + auto &sel_row = get_selected_row(i); + if (sel_row.rows().size() > 0) { + in_dim = framework::vectorize(sel_row.value().dims()); + break; + } + } in_dim[0] = static_cast(first_dim); out_value->Resize(framework::make_ddim(in_dim)); -- GitLab