CANN/pypto反量化函数文档
pypto.dequantize【免费下载链接】pyptoPyPTO发音: pai p-t-oParallel Tensor/Tile Operation编程范式。项目地址: https://gitcode.com/cann/pypto产品支持情况产品是否支持Ascend 950PR/Ascend 950DT√Atlas A3 训练系列产品/Atlas A3 推理系列产品√Atlas A2 训练系列产品/Atlas A2 推理系列产品√功能说明将量化后的低精度数据转换为高精度格式 并应用缩放(scale)和偏移(zero_points)参数当前支持输入DT_INT8/DT_INT16的Tensor反量化为DT_FP32的Tensor $$ \text{dst} ([float]\text{input} \text{zero_points}) * \text{scale} $$函数原型dequantize(input: Tensor, scale: Tensor, otype: DataType, axis: int, zero_points: Tensor) - Tensor参数说明参数名输入/输出说明input输入源操作数。支持的类型为Tensor。Tensor支持的数据类型为DT_INT8/DT_INT16;不支持空TensorShape仅支持2-4维Shape Size不大于2147483647即INT32_MAX。shape记为 [..., row, col]scale输入缩放因子。支持的类型为Tensor。Tensor数据类型与otype一致支持DT_FP32不支持空TensorShape比input少一位维仅支持1-3维Shape Size不大于2147483647即INT32_MAXaxis -1 或 input.shape.size() -1 时 shape [..., row]axis -2 或 input.shape.size() -2 时 shape [..., col]otype输入返回值的数值类型目前支持DT_FP32。axis输入指定反量化压缩的轴目前支持末尾两轴即 -1/-2 或者input.shape.size() -1/input.shape.size()-2zero_points输入可选的非对称量化的偏移因子支持的类型为Tensor。Tensor数据类型与otype一致支持DT_FP32支持空TensorShape比input少一位维仅支持1-3维Shape Size不大于2147483647即INT32_MAXaxis -1 或 input.shape.size() -1 时 shape [..., row]axis -2 或 input.shape.size() -2 时 shape [..., col]返回值说明返回输出TensorTensor的数据类型由otype指定Shape与input相同。调用示例TileShape设置示例说明调用该operation接口前应通过set_vec_tile_shapes设置TileShape。TileShape维度应和输出一致。示例1输入input shape为[m, n]输出为[m, n], TileShape设置为[m1, n1], 则m1, n1分别用于切分m, n轴。pypto.set_vec_tile_shapes(4, 16)接口调用示例x pypto.tensor([3, 4], pypto.DT_INT8) scale pypto.tensor([3, 1], pypto.DT_FP32) zero_points pypto.tensor([3, 1], pypto.DT_FP32) # fp32 - int8 对称反量化 y1 pypto.dequantize(x, scale, pypto.DT_FP32, -1, None) # fp32 - uint8 非对称反量化 y2 pypto.dequantize(x, scale, pypto.DT_FP32, -1, zero_points)结果示例如下Input x:[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] Input scale:[1.0, 1.0, 1.0] Input zero_points:[-2.0, -2.0, -2.0] Output y1:[[1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 3.0, 4.0], [1.0, 2.0, 3.0, 4.0]] Output y2:[[-1.0, 0.0, 1.0, 2.0], [-1.0, 0.0, 1.0, 2.0], [-1.0, 0.0, 1.0, 2.0]]【免费下载链接】pyptoPyPTO发音: pai p-t-oParallel Tensor/Tile Operation编程范式。项目地址: https://gitcode.com/cann/pypto创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考