Merged
增加quantOffsetOptional的shape说明 #9323
fengying555682Add on Aug 27
增加quantOffsetOptional的shape说明 #9323
Merged
Total: 1 files changed+43-43
| @@ -29,59 +29,59 @@ | |||
| 29 | 29 | ||
| 30 | 1. 根据输入数据类型x的不同,反量化路径不同: | 30 | 1. 根据输入数据类型x的不同,反量化路径不同: |
| 31 | 31 | ||
| 32 | -- INT8路径 | 32 | + - INT8路径 |
| 33 | 33 | ||
| 34 | - $$ | 34 | + $$ |
| 35 | - dequantOut_i = cast\_to\_float(x_i) \times weight\_scale_i + bias_i | 35 | + dequantOut_i = cast\_to\_float(x_i) \times weight\_scale_i + bias_i |
| 36 | - $$ | 36 | + $$ |
| 37 | 37 | ||
| 38 | -- INT32路径 | 38 | + - INT32路径 |
| 39 | 39 | ||
| 40 | - $$ | 40 | + $$ |
| 41 | - dequantOut_i = cast\_to\_float(x_i) \times weight\_scale_i \times activation\_scale_i + bias_i | 41 | + dequantOut_i = cast\_to\_float(x_i) \times weight\_scale_i \times activation\_scale_i + bias_i |
| 42 | - $$ | 42 | + $$ |
| 43 | 43 | ||
| 44 | -- BF16/FLOAT16路径(预反量化) | 44 | + - BF16/FLOAT16路径(预反量化) |
| 45 | 45 | ||
| 46 | - $$ | 46 | + $$ |
| 47 | - dequantOut_i = cast\_to\_float(x_i) | 47 | + dequantOut_i = cast\_to\_float(x_i) |
| 48 | - $$ | 48 | + $$ |
| 49 | 49 | ||
| 50 | -1. Situ激活 | 50 | +2. Situ激活 |
| 51 | 51 | ||
| 52 | -$$ | 52 | + $$ |
| 53 | -situ_a = \beta \times \tanh(gate / \beta) \times sigmoid(gate) | 53 | + situ_a = \beta \times \tanh(gate / \beta) \times sigmoid(gate) |
| 54 | -$$ | 54 | + $$ |
| 55 | 55 | ||
| 56 | -当linear_beta > 0时: | 56 | + 当linear_beta > 0时: |
| 57 | 57 | ||
| 58 | -$$ | 58 | + $$ |
| 59 | -up = linear\_beta \times \tanh(up / linear\_beta) | 59 | + up = linear\_beta \times \tanh(up / linear\_beta) |
| 60 | -$$ | 60 | + $$ |
| 61 | 61 | ||
| 62 | -$$ | 62 | + $$ |
| 63 | -situOut = situ_a \times up | 63 | + situOut = situ_a \times up |
| 64 | -$$ | 64 | + $$ |
| 65 | 65 | ||
| 66 | 其中,当activate_left为true时,gate取dequantOut的前半部分,up取后半部分;当activate_left为false时,gate取dequantOut的后半部分,up取前半部分。 | 66 | 其中,当activate_left为true时,gate取dequantOut的前半部分,up取后半部分;当activate_left为false时,gate取dequantOut的后半部分,up取前半部分。 |
| 67 | 67 | ||
| 68 | -2. 量化 | 68 | +3. 量化 |
| 69 | 69 | ||
| 70 | -- quant_type = static | 70 | + - quant_type = static |
| 71 | 71 | ||
| 72 | - $$ | 72 | + $$ |
| 73 | - y_i = trunc(situOut_i / quant\_scale_i + quant\_offset_i) | 73 | + y_i = trunc(situOut_i / quant\_scale_i + quant\_offset_i) |
| 74 | - $$ | 74 | + $$ |
| 75 | 75 | ||
| 76 | -- quant_type = dynamic | 76 | + - quant_type = dynamic |
| 77 | 77 | ||
| 78 | - $$ | 78 | + $$ |
| 79 | - scale_i = absmax(situOut_i) / 127 | 79 | + scale_i = absmax(situOut_i) / 127 |
| 80 | - $$ | 80 | + $$ |
| 81 | 81 | ||
| 82 | - $$ | 82 | + $$ |
| 83 | - y_i = trunc(situOut_i / scale_i) | 83 | + y_i = trunc(situOut_i / scale_i) |
| 84 | - $$ | 84 | + $$ |
| 85 | 85 | ||
| 86 | ## 函数原型 | 86 | ## 函数原型 |
| 87 | 87 | ||
| @@ -184,7 +184,7 @@ aclnnStatus aclnnDequantSituQuant( | |||
| 184 | <td>quantScaleOptional(aclTensor*)</td> | 184 | <td>quantScaleOptional(aclTensor*)</td> |
| 185 | <td>输入</td> | 185 | <td>输入</td> |
| 186 | <td>量化的scale。</td> | 186 | <td>量化的scale。</td> |
| 187 | - <td><ul><li>不支持空Tensor。</li><li>quant_type为static时必选,shape为(H,)或(1,)。</li><li>quant_type为dynamic时可选,作为smoothScale使用。</li><li>仅INT8使用。</li></ul></td> | 187 | + <td><ul><li>不支持空Tensor。</li><li>`quantTypeOptional`为static时必选,shape为(H,)或(1,)。</li><li>`quantTypeOptional`为dynamic时可选,作为smoothScale使用。</li><li>仅INT8使用。</li></ul></td> |
| 188 | <td>FLOAT</td> | 188 | <td>FLOAT</td> |
| 189 | <td>ND</td> | 189 | <td>ND</td> |
| 190 | <td>1</td> | 190 | <td>1</td> |
| @@ -194,7 +194,7 @@ aclnnStatus aclnnDequantSituQuant( | |||
| 194 | <td>quantOffsetOptional(aclTensor*)</td> | 194 | <td>quantOffsetOptional(aclTensor*)</td> |
| 195 | <td>输入</td> | 195 | <td>输入</td> |
| 196 | <td>量化的offset。</td> | 196 | <td>量化的offset。</td> |
| 197 | - <td><ul><li>不支持空Tensor。</li><li>仅当quant_type为static时有效。</li></ul></td> | 197 | + <td><ul><li>不支持空Tensor。</li><li>当`quantTypeOptional`为static时必选,shape同`quantScaleOptional`。</li><li>当`quantTypeOptional`为dynamic时可选。</li></ul></td> |
| 198 | <td>FLOAT</td> | 198 | <td>FLOAT</td> |
| 199 | <td>ND</td> | 199 | <td>ND</td> |
| 200 | <td>1</td> | 200 | <td>1</td> |
| @@ -264,7 +264,7 @@ aclnnStatus aclnnDequantSituQuant( | |||
| 264 | <td>yScaleOut(aclTensor*)</td> | 264 | <td>yScaleOut(aclTensor*)</td> |
| 265 | <td>输出</td> | 265 | <td>输出</td> |
| 266 | <td>动态量化的scale。</td> | 266 | <td>动态量化的scale。</td> |
| 267 | - <td><ul><li>不支持空Tensor。</li><li>INT8: shape为x.shape[:-1];其他: shape为[M]。</li><li>quant_type为static时输出无意义值。</li></ul></td> | 267 | + <td><ul><li>不支持空Tensor。</li><li>INT8: shape为x.shape[:-1];其他: shape为[M]。</li><li>`quantTypeOptional`为static时输出无意义值。</li></ul></td> |
| 268 | <td>FLOAT</td> | 268 | <td>FLOAT</td> |
| 269 | <td>ND</td> | 269 | <td>ND</td> |
| 270 | <td>1-7</td> | 270 | <td>1-7</td> |
| @@ -324,7 +324,7 @@ aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/co | |||
| 324 | <td>INT32时weightScaleOptional或activationScaleOptional为空指针。</td> | 324 | <td>INT32时weightScaleOptional或activationScaleOptional为空指针。</td> |
| 325 | </tr> | 325 | </tr> |
| 326 | <tr> | 326 | <tr> |
| 327 | - <td>quant_type为static时quantScaleOptional为空指针。</td> | 327 | + <td>`quantTypeOptional`为static时,`quantScaleOptional`为空指针。</td> |
| 328 | </tr> | 328 | </tr> |
| 329 | <tr> | 329 | <tr> |
| 330 | <td rowspan="6">ACLNN_ERR_PARAM_INVALID</td> | 330 | <td rowspan="6">ACLNN_ERR_PARAM_INVALID</td> |
| @@ -403,11 +403,11 @@ aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/co | |||
| 403 | - x的最后一维需要是2的倍数。 | 403 | - x的最后一维需要是2的倍数。 |
| 404 | - 当x的数据类型为INT8时,x维度≥2维;当x的数据类型为INT32/BF16/FLOAT16时,x维度为2维。 | 404 | - 当x的数据类型为INT8时,x维度≥2维;当x的数据类型为INT32/BF16/FLOAT16时,x维度为2维。 |
| 405 | - beta参数不能为0。 | 405 | - beta参数不能为0。 |
| 406 | -- INT8:必须提供weight_scale,禁止activation_scale和group_index。 | 406 | +- INT8:必须提供`weightScaleOptional`,禁止`activationScaleOptional`和`groupIndexOptional`。 |
| 407 | -- INT32:必须提供weight_scale和activation_scale,禁止quant_scale和quant_offset。 | 407 | +- INT32:必须提供`weightScaleOptional`和`activationScaleOptional`,禁止`quantScaleOptional`和`quantOffsetOptional`。 |
| 408 | - BF16/FLOAT16:所有可选输入均不使用(预反量化模式)。 | 408 | - BF16/FLOAT16:所有可选输入均不使用(预反量化模式)。 |
| 409 | -- 当quant_type为static时,quant_scale必须提供。 | 409 | +- 当`quantTypeOptional`为static时,`quantScaleOptional`必须提供。 |
| 410 | -- 当quant_type为dynamic时,quant_scale可选(作为smoothScale使用)。 | 410 | +- 当`quantTypeOptional`为dynamic时,`quantScaleOptional`可选(作为smoothScale使用)。 |
| 411 | 411 | ||
| 412 | ## 调用示例 | 412 | ## 调用示例 |
| 413 | 413 | ||