| 17 | "instead.") |
| 18 | |
| 19 | class Sequence(nn.Module): |
| 20 | def __init__(self): |
| 21 | super().__init__() |
| 22 | self.lstm1 = nn.LSTMCell(1, 51) |
| 23 | self.lstm2 = nn.LSTMCell(51, 51) |
| 24 | self.linear = nn.Linear(51, 1) |
| 25 | |
| 26 | def forward(self, input): |
| 27 | outputs = [] |
| 28 | h_t = torch.zeros(input.size(0), 51) |
| 29 | c_t = torch.zeros(input.size(0), 51) |
| 30 | h_t2 = torch.zeros(input.size(0), 51) |
| 31 | c_t2 = torch.zeros(input.size(0), 51) |
| 32 | |
| 33 | for input_t in input.split(1, dim=1): |
| 34 | h_t, c_t = self.lstm1(input_t, (h_t, c_t)) |
| 35 | h_t2, c_t2 = self.lstm2(h_t, (h_t2, c_t2)) |
| 36 | output = self.linear(h_t2) |
| 37 | outputs += [output] |
| 38 | outputs = torch.cat(outputs, dim=1) |
| 39 | return outputs |
| 40 | |
| 41 | class TestScriptProfile(JitTestCase): |
| 42 |
no outgoing calls
searching dependent graphs…