Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add THNN conversion of {oftShrink, Sqrt, Square, Tanh, Threshold}
- Loading branch information
1 parent
ccd562a
commit 83a17b2
Showing
12 changed files
with
273 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,22 @@ | ||
local Square, parent = torch.class('nn.Square','nn.Module') | ||
local Square, parent = torch.class('nn.Square', 'nn.Module') | ||
|
||
function Square:__init(args) | ||
parent.__init(self) | ||
end | ||
|
||
function Square:updateOutput(input) | ||
return input.nn.Square_updateOutput(self, input) | ||
input.THNN.Square_updateOutput( | ||
input:cdata(), | ||
self.output:cdata() | ||
) | ||
return self.output | ||
end | ||
|
||
function Square:updateGradInput(input, gradOutput) | ||
return input.nn.Square_updateGradInput(self, input, gradOutput) | ||
input.THNN.Square_updateGradInput( | ||
input:cdata(), | ||
gradOutput:cdata(), | ||
self.gradInput:cdata() | ||
) | ||
return self.gradInput | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
local Tanh = torch.class('nn.Tanh', 'nn.Module') | ||
|
||
function Tanh:updateOutput(input) | ||
return input.nn.Tanh_updateOutput(self, input) | ||
input.THNN.Tanh_updateOutput( | ||
input:cdata(), | ||
self.output:cdata() | ||
) | ||
return self.output | ||
end | ||
|
||
function Tanh:updateGradInput(input, gradOutput) | ||
return input.nn.Tanh_updateGradInput(self, input, gradOutput) | ||
input.THNN.Tanh_updateGradInput( | ||
input:cdata(), | ||
gradOutput:cdata(), | ||
self.gradInput:cdata(), | ||
self.output:cdata() | ||
) | ||
return self.gradInput | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.