Skip to content

Commit

Permalink
SpatialConvolution multithread fix
Browse files Browse the repository at this point in the history
Use the same instance of iSize to fix soumith#155
  • Loading branch information
jonathanasdf committed Apr 5, 2016
1 parent 728d477 commit 3eac63e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions SpatialConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function SpatialConvolution:__init(nInputPlane, nOutputPlane,
'nOutputPlane should be divisible by nGroups')
self.weight = torch.Tensor(nOutputPlane, nInputPlane/self.groups, kH, kW)
self.gradWeight = torch.Tensor(nOutputPlane, nInputPlane/self.groups, kH, kW)
self.iSize = torch.LongStorage(4):fill(0)
self:reset()
-- should nil for serialization, the reset will still work
self.reset = nil
Expand Down Expand Up @@ -99,11 +100,10 @@ function SpatialConvolution:createIODescriptors(input)
batch = false
end
assert(input:dim() == 4 and input:isContiguous());
self.iSize = self.iSize or torch.LongStorage(4):fill(0)
if not self.iDesc or not self.oDesc or
input:size(1) ~= self.iSize[1] or input:size(2) ~= self.iSize[2]
or input:size(3) ~= self.iSize[3] or input:size(4) ~= self.iSize[4] then
self.iSize = input:size()
self.iSize:copy(input:size())

assert(self.nInputPlane == input:size(2), 'input has to contain: '
.. self.nInputPlane
Expand Down

0 comments on commit 3eac63e

Please sign in to comment.