torch_npu.npu_slice(self, offsets, size) -> Tensor
从张量中提取切片。
该接口不支持反向计算。
1 2 3 4 5 6 7 | >>> input = torch.tensor([[1,2,3,4,5], [6,7,8,9,10]], dtype=torch.float16).to("npu") >>> offsets = [0, 0] >>> size = [2, 2] >>> output = torch_npu.npu_slice(input, offsets, size) >>> output tensor([[1., 2.], [6., 7.]], device='npu:0', dtype=torch.float16) |