diff --git a/paddle/fluid/operators/math/selected_rows_functor.cc b/paddle/fluid/operators/math/selected_rows_functor.cc index 305743b082a0c8b38053107a3924cb6cbef98948..75946740375d74043960b68e94eb048b3bab4b79 100644 --- a/paddle/fluid/operators/math/selected_rows_functor.cc +++ b/paddle/fluid/operators/math/selected_rows_functor.cc @@ -275,7 +275,7 @@ struct MergeAdd { } const framework::SelectedRows* has_value_input = nullptr; for (auto* in : inputs) { - if (!in->rows().empty()) { + if (in->rows().size() > 0) { has_value_input = in; break; } @@ -289,7 +289,7 @@ struct MergeAdd { framework::SelectedRows& out = *output; std::set merged_row_set; for (auto* input : inputs) { - if (input->rows().empty()) { + if (input->rows().size() == 0) { continue; } PADDLE_ENFORCE_EQ(input_width, input->value().dims()[1], @@ -319,7 +319,7 @@ struct MergeAdd { auto blas = math::GetBlas(context); for (auto* input : inputs) { - if (input->rows().empty()) { + if (input->rows().size() == 0) { continue; } auto* input_data = input->value().data(); diff --git a/paddle/fluid/operators/math/selected_rows_functor.cu b/paddle/fluid/operators/math/selected_rows_functor.cu index 7d94a45289053a2b9d176902382b30c0a010d0da..10f39822b9c904ce236a1a2a3806d70693bd2e63 100644 --- a/paddle/fluid/operators/math/selected_rows_functor.cu +++ b/paddle/fluid/operators/math/selected_rows_functor.cu @@ -311,7 +311,7 @@ struct MergeAdd { } const framework::SelectedRows* has_value_input = nullptr; for (auto* in : inputs) { - if (!in->rows().empty()) { + if (in->rows().size() > 0) { has_value_input = in; break; } @@ -325,7 +325,7 @@ struct MergeAdd { framework::SelectedRows& out = *output; std::set merged_row_set; for (auto* input : inputs) { - if (input->rows().empty()) { + if (input->rows().size() == 0) { continue; } PADDLE_ENFORCE_EQ(input_width, input->value().dims()[1], @@ -355,7 +355,7 @@ struct MergeAdd { dim3 threads(block_size, 1); for (auto* input : inputs) { - if (input->rows().empty()) { + if (input->rows().size() == 0) { continue; } auto* input_data = input->value().data(); diff --git a/paddle/fluid/operators/sum_op.h b/paddle/fluid/operators/sum_op.h index 69e619a5305020d2dc91485becb4e369006823f5..84b418bd307b7ba458bf340a81e0ee2036113be9 100644 --- a/paddle/fluid/operators/sum_op.h +++ b/paddle/fluid/operators/sum_op.h @@ -107,7 +107,7 @@ class SumKernel : public framework::OpKernel { } else { for (auto &in_var : in_vars) { auto &in = in_var->Get(); - if (!in.rows().empty()) { + if (in.rows().size() > 0) { inputs.push_back(&in_var->Get()); } }