The Tensor is now going to "view" the given DoubleStorage, starting at position storageOffset (>=1) with the given dimension sizes and the optional given strides. As the result, any modification in the elements of the Storage will have a impact on the elements of the Tensor, and vice-versa. This is an efficient method, as there is no memory copy!

  -- creates a storage with 10 elements
> s = torch.DoubleStorage(10):fill(1)

  -- we want to see it as a 2x5 tensor
> sz = torch.LongStorage(2)
> sz[1] = 2; sz[2] = 5;
> x = torch.Tensor()
> x:set(s, 1, sz)
> print(x)

 1  1  1  1  1
 1  1  1  1  1
[torch.Tensor of dimension 2x5]
> x:zero()
> print(s) -- the storage contents have been modified
> print(s)
0
0
0
0
0
0
0
0
0
0
[torch.DoubleStorage of size 10]

A shorcut which works up to 4 dimensional tensors exists.