该接口计划废弃,可以使用torch.fill_或torch.ones_like接口进行替换。
torch_npu.one_(self) -> Tensor
用1填充self张量。
“self” (Tensor):输入张量。
1 2 3 4 5 6 7 | >>> x = torch.rand(2, 3).npu() >>> x tensor([[0.8517, 0.1428, 0.0839], [0.1416, 0.9540, 0.9125]], device='npu:0') >>> torch_npu.one_(x) tensor([[1., 1., 1.], [1., 1., 1.]], device='npu:0') |