pytorch_lzwhard:

b = a[:, 0:2], I guess slice of a will copy to tensor b


nope, b and a share memory, though b is a new python wrapper object with different strides



 pytorch_lzwhard:

a[: 0:2] = a[:, 2:4],


here python’s object.__setitem__ mechanism is used instead, making partial assignment with copying possible