Skip to content

Instantly share code, notes, and snippets.

@killeent
Created January 9, 2017 21:46
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 killeent/e12e2d51a4cb533359867f05a5f3abeb to your computer and use it in GitHub Desktop.
Save killeent/e12e2d51a4cb533359867f05a5f3abeb to your computer and use it in GitHub Desktop.
soumith benchmarks
require 'torch'
require 'cutorch'
local trials = 5
print("----------------------------------------------------------------")
print("Soumith's Benchmarks (The times are the sum of", trials, "trials)")
print("----------------------------------------------------------------")
local tensors = {}
for i = 1, 32 do
table.insert(tensors, torch.CudaTensor(1, 600):uniform())
end
local timer = torch.Timer()
for i = 1, trials do
local catted = torch.cat(tensors, 1)
end
cutorch.synchronize()
local sum = timer:time().real
print("CatArray for 32 1x600 Tensors along dim=1 took", sum / trials, "seconds")
local tensors = {}
for i = 1, 128 do
table.insert(tensors, torch.CudaTensor(1, 32):uniform())
end
local timer = torch.Timer()
for i = 1, trials do
local catted = torch.cat(tensors, 1)
end
cutorch.synchronize()
local sum = timer:time().real
print("CatArray for 128 1x32 tensors along dim=1 took", sum / trials, "seconds")
local tensors = {}
for i = 1, 128 do
table.insert(tensors, torch.CudaTensor(1, 1024):uniform())
end
local timer = torch.Timer()
for i = 1, trials do
local catted = torch.cat(tensors, 1)
end
cutorch.synchronize()
local sum = timer:time().real
print("CatArray for 128 1x1024 tensors along dim=1 took", sum / trials, "seconds")
print('done')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment