MoeFinalizeRouting

产品支持情况

产品 是否支持
Ascend 950PR/Ascend 950DT ×
Atlas A3 训练系列产品/Atlas A3 推理系列产品
Atlas A2 训练系列产品/Atlas A2 推理系列产品
Atlas 200I/500 A2 推理产品 ×
Atlas 推理系列产品 ×
Atlas 训练系列产品 ×
Kirin X90 处理器系列产品
Kirin 9030 处理器系列产品

功能说明

  • 算子功能:MoE计算中,最后处理合并MoE FFN的输出结果。

  • 计算公式

    expertid=expandedExpertIdx[i,k]expertid=expandedExpertIdx[i,k]

    out(i,j)=x1i,j+x2Optionali,j+∑k=0K(scalesi,k∗(expandedXexpandedRowIdxi+k∗numrows,j+biasexpertid,j))out(i,j)=x1_{i,j}+x2Optional_{i,j}+\sum_{k=0}^{K}(scales_{i,k}*(expandedX_{expandedRowIdx_{i+k*num_rows},j}+bias_{expertid,j}))

参数说明

参数名 输入/输出/属性 描述 数据类型 数据格式
expandedX 输入 公式中的`expandedX` ,MoE的FFN输出。 FLOAT16、BFLOAT16、FLOAT32 ND
x1 输入 公式中的`x1`。 FLOAT16、BFLOAT16、FLOAT32 ND
x2Optional 输入 公式中的`x2Optional`。 FLOAT16、BFLOAT16、FLOAT32 ND
bias 输入 公式中的`bias`。 FLOAT16、BFLOAT16、FLOAT32 ND
scales 输入 公式中的`scales`。 FLOAT16、BFLOAT16、FLOAT32 ND
expandedRowIdx 输入 公式中的`expandedRowIdx`。 INT32 ND
expandedExpertIdx 输入 公式中的`expandedExpertIdx`。 INT32 ND
out 输出 公式中的`out`。 FLOAT16、BFLOAT16、FLOAT32 ND
  • Kirin X90/Kirin 9030 处理器系列产品: 不支持BFLOAT16。

约束说明

无。

调用说明

调用方式 样例代码 说明
aclnn接口 test_aclnn_moe_finalize_routing.cpp 通过aclnnMoeFinalizeRouting接口方式调用MoeFinalizeRouting算子。