Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable OMP multithreading in lookup_table_v2 #45249

Merged
merged 9 commits into from
Aug 25, 2022
4 changes: 4 additions & 0 deletions paddle/phi/kernels/cpu/embedding_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ struct EmbeddingCPUFunctor {
dev_ctx_.template Alloc<T>(out_);
auto* output = out_->data<T>();

#if defined(_OPENMP) && !defined(PADDLE_WITH_CUDA)
#pragma omp parallel for
#endif

for (int64_t i = 0; i < ids_numel; ++i) {
if (padding_idx_ != kNoPadding && ids[i] == padding_idx_) {
memset(output + i * row_width, 0, row_width * sizeof(T));
Expand Down