Skip to content

Instantly share code, notes, and snippets.

@santisy
Last active September 16, 2017 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save santisy/40842eaf393356013fe60d30267007c0 to your computer and use it in GitHub Desktop.
Save santisy/40842eaf393356013fe60d30267007c0 to your computer and use it in GitHub Desktop.
minimum example of strange speed change
import torch
import time
import numpy as np
time1 = time.time()
## double this tensor's second dimension(20->40), you will almost double the time
for _ in range(100):
tensor = torch.randn(5, 20, 128, 128)
array = np.zeros((128, 128), dtype=np.uint8)
tensor[1, 2, :, :] = torch.from_numpy(array).float()
time2 = time.time()
print "time past: %.4f" %((time2-time1)/100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment