jkoubele:

The PyTorch tensors share the memory buffer of NumPy ndarrays which may be part of the problem, hovewer I still don’t see how this translates to the sometimes longer torch.Tensor() call?


This shouldn’t be the case in your code snippet, as you are creating a new tensor and thus trigger a copy.
To share the same underlying data, you would have to use torch.from_numpy as seen here:
frame = np.ones((2, 2))
x = torch.Tensor(frame)

x[0, 0] = 2.
print(x) 
> tensor([[2., 1.],
          [1., 1.]])
print(frame)
> [[1. 1.]
   [1. 1.]]

y = torch.from_numpy(frame)
y[0, 0] = 2.
print(y)
> tensor([[2., 1.],
          [1., 1.]], dtype=torch.float64)
print(frame)
> [[2. 1.]
   [1. 1.]]