Skip to content

Commit

Permalink
add data_type support for phi embedding op.
Browse files Browse the repository at this point in the history
  • Loading branch information
limin2021 committed Mar 25, 2022
1 parent 54632b5 commit 79ff6e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 6 additions & 3 deletions paddle/phi/kernels/gpu/embedding_grad_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ void EmbeddingGradKernel(const Context& ctx,
functor.template apply<int>();
} else if (input.dtype() == phi::DataType::INT64) {
functor.template apply<int64_t>();
} else if (input.dtype() == phi::DataType::INT16) {
functor.template apply<int16_t>();
} else {
PADDLE_THROW(phi::errors::Unimplemented(
"emebdding input only support int32 and int64"));
"emebdding input only support int16, int32 and int64"));
}
}

Expand Down Expand Up @@ -233,9 +235,10 @@ void EmbeddingSparseGradKernel(const Context& ctx,
functor.template apply<int>();
} else if (input.dtype() == phi::DataType::INT64) {
functor.template apply<int64_t>();
} else {
} else if (input.dtype() == phi::DataType::INT16) {
functor.template apply<int16_t>();
PADDLE_THROW(phi::errors::Unimplemented(
"emebdding input only support int32 and int64"));
"emebdding input only support int16, int32 and int64"));
}
}

Expand Down
4 changes: 3 additions & 1 deletion paddle/phi/kernels/gpu/embedding_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ void EmbeddingKernel(const Context &ctx,
functor.template apply<int32_t>();
} else if (input.dtype() == phi::DataType::INT64) {
functor.template apply<int64_t>();
} else if (input.dtype() == phi::DataType::INT16) {
functor.template apply<int16_t>();
} else {
PADDLE_THROW(phi::errors::Unimplemented(
"emebdding input only support int32 and int64"));
"emebdding input only support int16, int32 and int64"));
}
}

Expand Down

1 comment on commit 79ff6e9

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.