torch_npu.npu_dynamic_quant(Tensor x, Tensor? smooth_scales=None) ->(Tensor, Tensor)
两个Tensor类型的输出:
PyTorch 2.1
Atlas A2 训练系列产品
import torch import torch_npu x = torch.rand((3, 3), dtype = torch.float16).to("npu") output, scale = torch_npu.npu_dynamic_quant(x) print(output) print(scale)
import torch import torch_npu x = torch.rand((3, 3), dtype = torch.float16).to("npu") smooth_scales = torch.rand((3,), dtype = torch.float16).to("npu") output, scale = torch_npu.npu_dynamic_quant(x, smooth_scales=smooth_scales) print(output) print(scale)