开发者
下载
[object Object]

[object Object][object Object]undefined
[object Object]
  • 接口功能:对张量x进行旋转变换,再执行对称动态量化。
  • 计算公式:
    1. 旋转变换

      Y=(x.reshape(,k)@rotation).reshape(m,n)Y = (x.\text{reshape}(*,k) @ \text{rotation}).\text{reshape}(m, n)

      其中:xRm×n\mathbf{x} \in \mathbb{R}^{m \times n}YRm×n\mathbf{Y} \in \mathbb{R}^{m \times n}rotationRk×k\mathbf{rotation} \in \mathbb{R}^{k \times k}

    2. 对称动态量化(pertoken 逐行量化)

      • 缩放因子计算(逐行计算)si=maxj[0, n1]Yi,jCMAXs_i = \frac{\max_{j \in [0,\ n-1]} |Y_{i,j}|}{C_{\text{MAX}}} 其中:sis_i 是第 ii 行的缩放因子;CMAXC_{\text{MAX}} 是量化范围最大值,int8 取127,quint4x2 取7。
      • 量化计算yi,j=Yi,jsiy_{i,j} = \frac{Y_{i,j}}{s_i}
[object Object]

每个算子分为,必须先调用“aclnnRotateQuantGetWorkspaceSize”接口获取入参并根据流程计算所需workspace大小,再调用“aclnnRotateQuant”接口执行计算。

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

    [object Object]
  • 返回值

    返回aclnnStatus状态码,具体参见

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

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

    [object Object]
  • 返回值

    返回aclnnStatus状态码,具体参见

[object Object]
  • [object Object]Atlas A3 训练系列产品/Atlas A3 推理系列产品[object Object]、[object Object]Atlas A2 训练系列产品/Atlas A2 推理系列产品[object Object]:
    • x的shape为(M, N),rotation的shape为(K, K)。
    • rotation的shape必须是方阵(K, K)。
    • x第二维的长度(N)必须是K的整数倍,N必须可以整除8。
    • 当yOut的输出类型为int8时,y的shape必须和x相同(M, N)。
    • 当yOut的输出类型为int32时,y的shape必须为(M, N//8)。
    • x和rotation的数据类型必须相同。
    • scaleOut的shape必须是(M)。
    • N的范围为[128, 16000]。
    • K的范围为[16, 1024]。
[object Object]

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

[object Object]