How to set value of a Tensor with numpy array

I’m looking for tensor.set_value() and tensor.get_value() equivalence in pytorch. For tensor.get_value() it seems Tensor.numpy() meets the demand, but for tensor.set_value() I got no clue.

So, is there any way to set value of a pytorch tensor with numpy array? torch.from_numpy() returns a new Tensor, so it’s not the right answer.

I just realized that what Tensor.numpy() returns is a pointer, with which Tensor's value can be modified. It works for cpu tensors, not tested yet for gpu tensors.

Is this what you are looking for ?