-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.lua
More file actions
38 lines (34 loc) · 900 Bytes
/
test.lua
File metadata and controls
38 lines (34 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'openblas-conv'
torch.setdefaulttensortype('torch.FloatTensor')
function fill(t)
s = t:storage()
for i=1,s:size() do
s[i] = i % 100 * 0.01
end
end
function test(enable, partial)
openblasconv(enable, partial)
input = torch.Tensor(3,720,1280)
n = nn.SpatialConvolutionMM(3,8,5,5,1,1,2,2)
fill(input)
fill(n.weight)
fill(n.bias)
fill(n.gradBias)
fill(n.gradWeight)
sys.tic()
for i = 1,100 do
output = n:forward(input)
end
print('forward', enable, partial, output:sum(), sys.toc())
gradOutput = torch.Tensor(output:size(1), output:size(2), output:size(3))
fill(gradOutput)
sys.tic()
for i = 1,100 do
gradInput = n:backward(input, gradOutput)
end
print('backward', enable, partial, gradInput:sum(), sys.toc())
collectgarbage()
end
test(true)
test(true,true)
test(false)