Skip to content

Commit

Permalink
add data_type support for phi embedding op. (#40964)
Browse files Browse the repository at this point in the history
  • Loading branch information
limin2021 authored Mar 27, 2022
1 parent 1c6dcfd commit de8962b
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

0 comments on commit de8962b

Please sign in to comment.