提交 41372ded 编写于 作者: Q qingqing01

Resume CPU implenmentation.

上级 32d881be
......@@ -312,23 +312,12 @@ struct RowwiseAdd<platform::CPUDeviceContext, T> {
PADDLE_ENFORCE_EQ(vector.numel(), size);
PADDLE_ENFORCE_EQ(output->dims(), in_dims);
// auto in = framework::EigenMatrix<T>::From(input);
// auto vec = framework::EigenVector<T>::Flatten(vector);
// auto out = framework::EigenMatrix<T>::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<T>();
auto* vec = vector.data<T>();
auto* out = output->data<T>();
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<T>::From(input);
auto vec = framework::EigenVector<T>::Flatten(vector);
auto out = framework::EigenMatrix<T>::From(*output);
for (int64_t i = 0; i < in_dims[0]; ++i) {
out.chip(i, 0) = in.chip(i, 0) + vec;
}
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册