torch_npu.npu_format_cast_(self, src) -> Tensor
原地修改self张量格式,与src格式保持一致。src,即source tensor,源张量。
1 2 3 4 5
>>> x = torch.rand(2, 3, 4, 5).npu() >>> torch_npu.get_npu_format(x) 0 >>> torch_npu.get_npu_format(torch_npu.npu_format_cast_(x, 2)) 2