The Tensor
is now going to "view" the same storage
than the given tensor
. As the result, any modification in the elements of
the Tensor
will have a impact on the elements of the given tensor
, and
vice-versa. This is an efficient method, as there is no memory copy!
> x = torch.Tensor(2,5):fill(3.14) > print(x) 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 [torch.Tensor of dimension 2x5] > y = torch.Tensor():set(x) > print(y) 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 3.1400 [torch.Tensor of dimension 2x5] > y:zero() > print(x) -- elements of x are the same than y! 0 0 0 0 0 0 0 0 0 0 [torch.Tensor of dimension 2x5]