开发者
资源
[object Object]

[object Object][object Object]undefined
[object Object]
  • 接口功能:MoE计算中,对x的输出做Softmax计算,取topK操作。其中yOut为softmax的topK结果;expertIdxOut为topK的值的索引结果,即对应的专家序号;rowIdxOut为与expertIdxOut相同shape的列取值结果,指示每个位置对应的原始行位置。如果expertIdxOut中对应的行的finished为True,则直接填num_expert值(即x的最后一个轴大小)。
  • 计算公式:softmaxOut=softmax(x,axis=1)softmaxOut=softmax(x,axis=-1) yOut,expertIdxOut=topK(softmaxOut,k=k)yOut,expertIdxOut=topK(softmaxOut,k=k) rowIdxRange=arange(expertIdxOut.shape[0]expertIdxOut.shape[1])rowIdxRange=arange(expertIdxOut.shape[0]*expertIdxOut.shape[1]) rowIdxOut=rowIdxRange.reshape([expertIdxOut.shape[1],expertIdxOut.shape[0]]).transpose(1,0)rowIdxOut=rowIdxRange.reshape([expertIdxOut.shape[1],expertIdxOut.shape[0]]).transpose(1,0)
[object Object]

每个算子分为,必须先调用“aclnnMoeGatingTopKSoftmaxGetWorkspaceSize”接口获取计算所需workspace大小以及包含了算子计算流程的执行器,再调用“aclnnMoeGatingTopKSoftmax”接口执行计算。

[object Object]
[object Object]
[object Object]
  • 参数说明:

    [object Object]
  • 返回值:

    aclnnStatus:返回状态码,具体参见

    第一段接口完成入参校验,出现以下场景时报错:

    [object Object]
[object Object]
  • 参数说明:

    [object Object]
  • 返回值

    aclnnStatus:返回状态码,具体参见

[object Object]
  • 确定性计算:

    • aclnnMoeGatingTopKSoftmax默认确定性实现。
  • Atlas 350 加速卡:

    • x最后一维的大小(即专家数)取值范围为[1, 2048]。
[object Object]

示例代码如下,仅供参考,具体编译和执行过程请参考

[object Object]