Skip to content

Commit 841227a

Browse files
committed
fixing table modules to return correct number of gradInputs
1 parent 194522f commit 841227a

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

CAddTable.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ function CAddTable:updateGradInput(input, gradOutput)
2020
self.gradInput[i]:resizeAs(input[i])
2121
self.gradInput[i]:copy(gradOutput)
2222
end
23+
24+
for i=#input+1, #self.gradInput do
25+
self.gradInput[i] = nil
26+
end
27+
2328
return self.gradInput
2429
end

CDivTable.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ function CDivTable:updateGradInput(input, gradOutput)
1717
self.gradInput[2] = self.gradInput[2] or input[1].new()
1818
self.gradInput[1]:resizeAs(input[1]):copy(gradOutput):cdiv(input[2])
1919
self.gradInput[2]:resizeAs(input[2]):zero():addcdiv(-1,self.gradInput[1],input[2]):cmul(input[1])
20+
21+
for i=#input+1, #self.gradInput do
22+
self.gradInput[i] = nil
23+
end
24+
2025
return self.gradInput
2126
end

CMulTable.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ function CMulTable:updateGradInput_efficient(input, gradOutput)
2323
self.tout:copy(self.output):cdiv(input[i])
2424
self.gradInput[i]:cmul(self.tout)
2525
end
26+
27+
for i=#input+1, #self.gradInput do
28+
self.gradInput[i] = nil
29+
end
30+
2631
return self.gradInput
2732
end
2833

@@ -36,6 +41,10 @@ function CMulTable:updateGradInput(input, gradOutput)
3641
end
3742
end
3843
end
44+
45+
for i=#input+1, #self.gradInput do
46+
self.gradInput[i] = nil
47+
end
48+
3949
return self.gradInput
4050
end
41-

CSubTable.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@ function CSubTable:updateGradInput(input, gradOutput)
1717
self.gradInput[2] = self.gradInput[2] or input[1].new()
1818
self.gradInput[1]:resizeAs(input[1]):copy(gradOutput)
1919
self.gradInput[2]:resizeAs(input[2]):copy(gradOutput):mul(-1)
20+
21+
for i=#input+1, #self.gradInput do
22+
self.gradInput[i] = nil
23+
end
24+
2025
return self.gradInput
2126
end

0 commit comments

Comments
 (0)