File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
beginner_source/examples_autograd Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,11 @@ def forward(ctx, input):
33
33
"""
34
34
In the forward pass we receive a Tensor containing the input and return
35
35
a Tensor containing the output. ctx is a context object that can be used
36
- to stash information for backward computation. You can cache arbitrary
37
- objects for use in the backward pass using the ctx.save_for_backward method.
36
+ to stash information for backward computation. You can cache tensors for
37
+ use in the backward pass using the ``ctx.save_for_backward`` method. Other
38
+ objects can be stored directly as attributes on the ctx object, such as
39
+ ``ctx.my_object = my_object``. Check out `Extending torch.autograd <https://docs.pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd>`_
40
+ for further details.
38
41
"""
39
42
ctx .save_for_backward (input )
40
43
return 0.5 * (5 * input ** 3 - 3 * input )
You can’t perform that action at this time.
0 commit comments