diff options
Diffstat (limited to 'benchmark/torch7capi.lua')
-rw-r--r-- | benchmark/torch7capi.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/benchmark/torch7capi.lua b/benchmark/torch7capi.lua new file mode 100644 index 0000000..4694f2a --- /dev/null +++ b/benchmark/torch7capi.lua @@ -0,0 +1,31 @@ +require 'torch' + +local SZ = tonumber(arg[1]) +local N = tonumber(arg[2]) +local scale = tonumber(arg[3]) or 1 + +torch.manualSeed(1111) + +local x = torch.rand(SZ,SZ) +local y = torch.rand(SZ,SZ) + +print('x', x:norm()) +print('y', x:norm()) +print('running') + +local clk = os.clock() +if scale == 1 then + for i=1,N do + torch.add(y, x, 5) + torch.add(y, x, y) + end +else + for i=1,N do + torch.add(y, x, 5) + torch.add(y, x, scale, y) + end +end +print('time (s)', os.clock()-clk) + +print('x', x:norm()) +print('y', y:norm()) |