npu_moe_compute_expert_tokens(Tensor sorted_expert_for_source_row, int num_expert) -> Tensor
expertTokens:Device侧的aclTensor,公式中的输出,要求的是一个1D的Tensor,数据类型与sorted_expert_for_source_row保持一致。
无。
Atlas A2 训练系列产品
import torch import torch_npu sorted_experts = torch.tensor([3,3,4,5,6,7], dtype=torch.int32) num_experts = 5 output = torch_npu.npu_moe_compute_expert_tokens(sorted_experts.npu(), num_experts)