Copying from a Variable to a numpy slice without doing .data.numpy()
first takes a few seconds to perform, even with small tensors.
tensor = torch.randn(1000, 10)
variable = Variable(tensor)
array = np.empty((10000, 10))
array[0:1000] = variable # Slow (7.49 s!)
array[1000:2000] = variable.data.numpy() # (5.73 µs)