From 41372ded20f18d8367b76aee792b6499117a3ce6 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Tue, 26 Dec 2017 06:03:45 -0800 Subject: [PATCH] Resume CPU implenmentation. --- paddle/operators/math/math_function.cc | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/paddle/operators/math/math_function.cc b/paddle/operators/math/math_function.cc index 1a4829c49f7..d4f12f0a106 100644 --- a/paddle/operators/math/math_function.cc +++ b/paddle/operators/math/math_function.cc @@ -312,23 +312,12 @@ struct RowwiseAdd { PADDLE_ENFORCE_EQ(vector.numel(), size); PADDLE_ENFORCE_EQ(output->dims(), in_dims); - // auto in = framework::EigenMatrix::From(input); - // auto vec = framework::EigenVector::Flatten(vector); - // auto out = framework::EigenMatrix::From(*output); - // for (int64_t i = 0; i < in_dims[0]; ++i) { - // out.chip(i, 0) = in.chip(i, 0) + vec; - // } - - auto* in = input.data(); - auto* vec = vector.data(); - auto* out = output->data(); - - int64_t h = in_dims[0]; - int64_t w = in_dims[1]; - for (int64_t i = 0; i < h; ++i) { - for (int64_t j = 0; j < w; ++j) { - out[i * w + j] = in[i * w + j] + vec[j]; - } + auto in = framework::EigenMatrix::From(input); + auto vec = framework::EigenVector::Flatten(vector); + auto out = framework::EigenMatrix::From(*output); + + for (int64_t i = 0; i < in_dims[0]; ++i) { + out.chip(i, 0) = in.chip(i, 0) + vec; } } }; -- GitLab