torch_npu.npu_sign_bits_unpack

API接口

torch_npu.npu_sign_bits_unpack(x, dtype, size) -> Tensor

功能描述

将uint8类型1位Adam拆包为float。

参数说明

约束说明

Size可被uint8s拆包的输出整除。输出大小为(size of x) * 8。

示例

    >>>a = torch.tensor([159, 15], dtype=torch.uint8).npu()
    >>>b = torch_npu.npu_sign_bits_unpack(a, 0, 2)
    >>>b
    >>>tensor([[1., 1., 1., 1., 1., -1., -1., 1.],
    >>>[1., 1., 1., 1., -1., -1., -1., -1.]], device='npu:0')
(binary form of 159 is ob00001111)