-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVolumetricMaxPooling.lua
62 lines (49 loc) · 1.33 KB
/
VolumetricMaxPooling.lua
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local VolumetricMaxPooling, parent = torch.class('nn.VolumetricMaxPooling', 'nn.Module')
VolumetricMaxPooling.__version = 2
function VolumetricMaxPooling:__init(kT, kW, kH, dT, dW, dH, padT, padW, padH)
parent.__init(self)
dT = dT or kT
dW = dW or kW
dH = dH or kH
self.kT = kT
self.kH = kH
self.kW = kW
self.dT = dT
self.dW = dW
self.dH = dH
self.padT = padT or 0
self.padW = padW or 0
self.padH = padH or 0
self.ceil_mode = false
self.indices = torch.Tensor()
end
function VolumetricMaxPooling:ceil()
self.ceil_mode = true
return self
end
function VolumetricMaxPooling:floor()
self.ceil_mode = false
return self
end
function VolumetricMaxPooling:updateOutput(input)
input.nn.VolumetricMaxPooling_updateOutput(self, input)
return self.output
end
function VolumetricMaxPooling:updateGradInput(input, gradOutput)
input.nn.VolumetricMaxPooling_updateGradInput(self, input, gradOutput)
return self.gradInput
end
function VolumetricMaxPooling:empty()
self.gradInput:resize()
self.gradInput:storage():resize(0)
self.output:resize()
self.output:storage():resize(0)
self.indices:resize()
self.indices:storage():resize(0)
end
function VolumetricMaxPooling:read(file, version)
parent.read(self, file)
if version < 2 then
self.ceil_mode = false
end
end