Skip to content

Commit

Permalink
Merge pull request #87 from szagoruyko/volconsistency
Browse files Browse the repository at this point in the history
VolumetricConvolution consistent with nn
  • Loading branch information
soumith committed Jan 5, 2016
2 parents ea419e5 + cd2ee61 commit 4fdde0a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 3 additions & 1 deletion SpatialConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function SpatialConvolution:__init(nInputPlane, nOutputPlane,
self:reset()
-- should nil for serialization, the reset will still work
self.reset = nil
self.iSize = torch.LongStorage(4):fill(0)
end

-- if you change the configuration of the module manually, call this
Expand Down Expand Up @@ -56,6 +55,7 @@ end
function SpatialConvolution:fastest(mode)
if mode == nil then mode = true end
self.fastest_mode = mode
self.iSize = self.iSize or torch.LongStorage(4)
self.iSize:fill(0)
return self
end
Expand All @@ -70,6 +70,7 @@ function SpatialConvolution:setMode(fmode, bdmode, bwmode)
if bwmode ~= nil then
self.bwmode = bwmode
end
self.iSize = self.iSize or torch.LongStorage(4)
self.iSize:fill(0)
return self
end
Expand All @@ -88,6 +89,7 @@ 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
Expand Down
14 changes: 3 additions & 11 deletions VolumetricConvolution.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ local VolumetricConvolution, parent
local ffi = require 'ffi'
local errcheck = cudnn.errcheck

function VolumetricConvolution:__init(nInputPlane, nOutputPlane,
kT, kW, kH,
dT, dW, dH,
padT, padW, padH)
parent.__init(self, nInputPlane, nOutputPlane, kT, kW, kH, dT, dW, dH)
self.padT = padT or 0
self.padW = padW or 0
self.padH = padH or 0
self.iSize = torch.LongStorage(5):fill(0)
end

-- if you change the configuration of the module manually, call this
function VolumetricConvolution:resetWeightDescriptors()
assert(torch.typename(self.weight) == 'torch.CudaTensor',
Expand Down Expand Up @@ -41,6 +30,7 @@ end
function VolumetricConvolution:fastest(mode)
if mode == nil then mode = true end
self.fastest_mode = mode
self.iSize = self.iSize or torch.LongStorage(4)
self.iSize:fill(0)
return self
end
Expand All @@ -55,6 +45,7 @@ function VolumetricConvolution:setMode(fmode, bdmode, bwmode)
if bwmode ~= nil then
self.bwmode = bwmode
end
self.iSize = self.iSize or torch.LongStorage(4)
self.iSize:fill(0)
return self
end
Expand All @@ -74,6 +65,7 @@ function VolumetricConvolution:createIODescriptors(input)
batch = false
end
assert(input:dim() == 5 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]
Expand Down

0 comments on commit 4fdde0a

Please sign in to comment.