开发者
下载
[object Object]

[object Object][object Object]undefined
[object Object]
  • 接口功能:根据输入的scale对输入x进行分组量化,并分组计算输入x的绝对值的最大值amax。

  • 计算公式:

    group_listgroup\_list 沿 dim-0 将 xx 切分为 num_groups 组,group_list[g]group\_list[g] 为前 g+1g+1 组在 dim-0 上的累计大小(单调递增,group_list[1]=x.shape[0]group\_list[-1]=x.shape[0])。对每个group(g = 0, 1, ..., num_groups - 1):

    x_g=x[group_list[g1]:group_list[g],...]x\_g = x[group\_list[g-1] : group\_list[g], ...] y=Cast(x_g×scale[g],dst_type,round_mode)y = \text{Cast}(x\_g \times scale[g], \text{dst\_type}, \text{round\_mode}) amax[g]=max(x_g)amax[g] = \max(|x\_g|)

    其中,xx 表示输入张量,x_gx\_g 表示输入张量的第g组数据,g=0 时下界为0;scalescale 表示量化缩放因子,amax[g]amax[g] 为输入张量对应group组绝对值的最大值,dst_type\text{dst\_type}指定输出类型,round_mode\text{round\_mode}指定舍入模式。

[object Object]

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

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

    [object Object]
  • 返回值

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

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

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

    [object Object]
  • 返回值

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

[object Object]
  • 确定性计算:
    • aclnnGroupedQuantMax默认确定性实现。
[object Object]

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

[object Object]