Skip to content

Commit dd5f390

Browse files
authored
Merge pull request #708 from ailzhang/fix_indent
Make jit tutorial consistently using 4 spaces as indent.
2 parents 917cad5 + 79384c9 commit dd5f390

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

beginner_source/Intro_to_TorchScript_tutorial.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
3232
"""
3333

34-
import torch # This is all you need to use both PyTorch and TorchScript!
34+
import torch # This is all you need to use both PyTorch and TorchScript!
3535
print(torch.__version__)
3636

3737

@@ -125,11 +125,11 @@ def forward(self, x, h):
125125
#
126126

127127
class MyDecisionGate(torch.nn.Module):
128-
def forward(self, x):
129-
if x.sum() > 0:
130-
return x
131-
else:
132-
return -x
128+
def forward(self, x):
129+
if x.sum() > 0:
130+
return x
131+
else:
132+
return -x
133133

134134
class MyCell(torch.nn.Module):
135135
def __init__(self):
@@ -256,11 +256,11 @@ def forward(self, x, h):
256256
#
257257

258258
class MyDecisionGate(torch.nn.Module):
259-
def forward(self, x):
260-
if x.sum() > 0:
261-
return x
262-
else:
263-
return -x
259+
def forward(self, x):
260+
if x.sum() > 0:
261+
return x
262+
else:
263+
return -x
264264

265265
class MyCell(torch.nn.Module):
266266
def __init__(self, dg):
@@ -342,13 +342,13 @@ def forward(self, xs):
342342
#
343343

344344
class WrapRNN(torch.nn.Module):
345-
def __init__(self):
346-
super(WrapRNN, self).__init__()
347-
self.loop = torch.jit.script(MyRNNLoop())
345+
def __init__(self):
346+
super(WrapRNN, self).__init__()
347+
self.loop = torch.jit.script(MyRNNLoop())
348348

349-
def forward(self, xs):
350-
y, h = self.loop(xs)
351-
return torch.relu(y)
349+
def forward(self, xs):
350+
y, h = self.loop(xs)
351+
return torch.relu(y)
352352

353353
traced = torch.jit.trace(WrapRNN(), (torch.rand(10, 3, 4)))
354354
print(traced.code)

0 commit comments

Comments
 (0)