[XPU] Fix the error in MoeExpertFFN operator when valid_token_num=0 (#5196)

This commit is contained in:
zccjjj
2025-11-25 10:07:20 +08:00
committed by GitHub
parent 09b47c7111
commit ea3bc5b4ca

View File

@@ -441,7 +441,7 @@ std::vector<paddle::Tensor> MoeExpertFFN(
const std::string& quant_method,
const int hadamard_blocksize,
const int valid_token_num) {
if (ffn_in.numel() == 0) {
if (ffn_in.numel() == 0 || valid_token_num == 0) {
paddle::Tensor ffn2_out =
paddle::empty_like(ffn_in, paddle::DataType::BFLOAT16);
return {ffn2_out};