MCPcopy Create free account
hub / github.com/pytorch/pytorch / Sequence

Class Sequence

test/jit/test_script_profile.py:19–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 "instead.")
18
19class 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
41class TestScriptProfile(JitTestCase):
42

Callers 4

test_basicMethod · 0.70
test_scriptMethod · 0.70
test_multiMethod · 0.70
test_sectionMethod · 0.70

Calls

no outgoing calls

Tested by 4

test_basicMethod · 0.56
test_scriptMethod · 0.56
test_multiMethod · 0.56
test_sectionMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…