torch.utils.swap_tensors torch.utils.swap_tensors(t1, t2)[源代码] 此函数交换两个张量对象的内容。总体而言,t1 将拥有 t2 的内容,但会保留其身份。 如果 t1 和 t2 的槽不同,这将无法工作。