Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/threads-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/benchmark-threaded.lua')
-rw-r--r--benchmark/benchmark-threaded.lua75
1 files changed, 49 insertions, 26 deletions
diff --git a/benchmark/benchmark-threaded.lua b/benchmark/benchmark-threaded.lua
index bcf4e65..6220795 100644
--- a/benchmark/benchmark-threaded.lua
+++ b/benchmark/benchmark-threaded.lua
@@ -20,6 +20,7 @@ cmd:option('-convmm', false, 'use "mm" convolution code instead of standard')
cmd:option('-sub', false, 'use subsampling instead of max pooling')
cmd:option('-openmp', false, 'use openmp *package*')
cmd:option('-double', false, 'use doubles instead of floats')
+cmd:option('-half', false, 'use halves instead of floats')
cmd:option('-cuda', false, 'use CUDA instead of floats')
cmd:option('-gi', false, 'compute gradInput')
cmd:option('-v', false, 'be verbose')
@@ -97,19 +98,41 @@ if not params.sub then
end
end
-if params.double and params.cuda then
- error('make your choice between double and cuda!!')
+local function gpuType()
+ if params.double then
+ return 'torch.CudaDoubleTensor'
+ elseif params.half then
+ return 'torch.CudaHalfTensor'
+ else
+ return 'torch.CudaTensor'
+ end
+end
+
+local function cpuType()
+ if params.double then
+ return 'torch.DoubleTensor'
+ elseif params.half then
+ return 'torch.FloatTensor'
+ else
+ return 'torch.FloatTensor'
+ end
+end
+
+if params.double and params.half then
+ error('make your choice between double and half!!')
+end
+
+if params.half and not params.cuda then
+ error('half not supported without cuda')
end
-if params.double then
- torch.setdefaulttensortype('torch.DoubleTensor')
-elseif params.cuda then
+if params.cuda then
require 'cunn'
- dofile('cudahacks.lua')
- torch.setdefaulttensortype('torch.CudaTensor')
+ --dofile('cudahacks.lua')
+ torch.setdefaulttensortype(gpuType())
print( cutorch.getDeviceProperties(cutorch.getDevice()) )
else
- torch.setdefaulttensortype('torch.FloatTensor')
+ torch.setdefaulttensortype(cpuType())
end
local noutput = 10
@@ -149,8 +172,8 @@ if not params.nomlp then
mlp:add(nn.Linear(ninput, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -165,7 +188,7 @@ if not params.nomlp then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()
@@ -181,8 +204,8 @@ if not params.nomlp then
mlp:add(nn.Linear(500, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -197,7 +220,7 @@ if not params.nomlp then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()
@@ -218,8 +241,8 @@ if not params.nomlp then
mlp:add(nn.Linear(1000, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -234,7 +257,7 @@ if not params.nomlp then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()
@@ -272,8 +295,8 @@ if not params.nocnn then
mlp:add(nn.Linear(120, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -288,7 +311,7 @@ if not params.nocnn then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()
@@ -314,8 +337,8 @@ if not params.nocnn then
mlp:add(nn.Linear(120, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -330,7 +353,7 @@ if not params.nocnn then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()
@@ -356,8 +379,8 @@ if not params.nocnn then
mlp:add(nn.Linear(120, noutput))
if params.cuda then
- mlp:add(nn.Copy('torch.CudaTensor', 'torch.FloatTensor'))
- torch.setdefaulttensortype('torch.FloatTensor')
+ mlp:add(nn.Copy(gpuType(), cpuType()))
+ torch.setdefaulttensortype(cpuType())
end
mlp:add(nn.LogSoftMax())
@@ -372,7 +395,7 @@ if not params.nocnn then
local criterion = nn.ClassNLLCriterion()
if params.cuda then
- torch.setdefaulttensortype('torch.CudaTensor')
+ torch.setdefaulttensortype(gpuType())
end
local t = torch.Timer()