Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Contiguous.lua - github.com/torch/nn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f9974ce5ae004f742862055ba4ddfcd30dabc9e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local Contiguous, parent = torch.class('nn.Contiguous', 'nn.Module')

function Contiguous:updateOutput(input)
   if not input:isContiguous() then
      if self.output:storage() == input:storage() then self.output:set() end
      self.output:resizeAs(input):copy(input)
   else
      self.output:set(input)
   end
   return self.output
end

function Contiguous:updateGradInput(input, gradOutput)
   if not gradOutput:isContiguous() then
      if self.gradInput:storage() == gradOutput:storage() then self.gradInput:set() end
      self.gradInput:resizeAs(gradOutput):copy(gradOutput)
   else
      self.gradInput:set(gradOutput)
   end
   return self.gradInput
end