Copy
InplaceFunction
- class tensorplay.autograd.function.InplaceFunction[source]
In-place operations must call
ctx.mark_dirtyon the mutated inputs insideforward; this subclass exists only so historical code that subclasses it keeps working.- classmethod apply(*args, **kwargs)
Runs the operation and attaches gradient bookkeeping to outputs.
flat arguments computes
needs_input_gradand wires next-edges BEFORE forward; outputs are marked and attached AFTERsetup_context. When the fused C++ helpers are present the hot path makes two pybind crossings total (graph setup + output attach); otherwise a generic Python fallback runs.
- static backward(ctx, *grad_outputs)
Defines a formula for differentiating the operation.
- static forward(ctx, *args, **kwargs)
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 outputUsage 2 (Separated forward and ctx):
@staticmethod def forward(input1, input2): ... return output @staticmethod def setup_context(ctx, inputs, output): ...
- static jvp(ctx, *grad_inputs)
Defines a formula for computing the jacobian-vector product.
Not yet supported by this engine; provided for API compatibility.
- static setup_context(ctx, inputs, output)
Sets up the context object (Usage 2 above).
- static vmap(info, in_dims, *args)
Defines a formula for vectorizing the operation.
Not yet supported by this engine; provided for API compatibility.
Help improve this page
Found an error, an unclear step, or a missing example?

