Copy
Function
- class tensorplay.autograd.function.Function[source]
Records operation history and defines formulas for differentiating ops.
Supports two styles, mirroring torch.autograd.Function:
Legacy style:
forward(ctx, ...)/backward(ctx, ...)(forward receives a context object).Combined-forward style: define
forward(*args, **kwargs),setup_context(ctx, inputs, output)and usesave_for_backward/save_for_forwardinsidesetup_contextinstead of receiving actxargument inforward.
- classmethod apply(*args, **kwargs)[source]
Runs the operation and attaches gradient bookkeeping to outputs.
- static backward(ctx, *grad_outputs)[source]
Defines a formula for differentiating the operation.
- static forward(ctx, *args, **kwargs)[source]
Performs the operation.
This function is to be overridden by all subclasses. There are two ways to define forward:
Usage 1 (Combined forward and ctx):
@staticmethod def forward(ctx, input1, input2): ... return output
Usage 2 (Separated forward and ctx):
@staticmethod def forward(input1, input2): ... return output @staticmethod def setup_context(ctx, inputs, output): ...
- static jvp(ctx, *grad_inputs)[source]
Defines a formula for computing the jacobian-vector product.
Not yet supported by this engine; provided for API parity.
- static setup_context(ctx, inputs, output)[source]
Sets up the context object (Usage 2 above).
- static vmap(info, in_dims, *args)[source]
Defines a formula for vectorizing the operation.
Not yet supported by this engine; provided for API parity.
Help improve this page
Found an error, an unclear step, or a missing example?
