CRTP base for runtime-variable-arity op kernels.
Inherits Node directly (not AutogradNode\<Derived, N\>)
so the saved-input and edge containers can grow at runtime, and
IKernel for polymorphic invocation. Derived ops own their
own forward() and apply() — only the autograd wiring helper
is shared.
Template Parameters
Derived : class The concrete CRTP self-type.
See Also
NaryKernel — fixed-arity sibling using std::array.
UnaryKernel, BinaryKernel.
IKernel — the abstract base above the CRTP layer.
Attributes
input_tensors_v_std::vector<std::weak_ptr<TensorImpl>>input_shapes_v_std::vector<Shape>out_shape_Shapedtype_Dtypedevice_Devicesaved_inputs_v_std::vector<Storage>Storage at forward time, populated when wire_autograd is called with save_ins=true.saved_output_StorageNotes
All inputs must share dtype and device — wire_autograd does
not validate this; the concrete op's forward() is expected
to have already enforced consistency before calling wire_autograd.
validate_versions walks the runtime vector and invokes
check_version_match per input.
Static methods
1wire_autograd
→boolbool wire_autograd(int bwd, const int & inputs, const int & out, bool save_ins)Attach an existing backward node to the autograd graph.
Parameters
bwdstd::shared_ptr<Derived>out.inputsconst std::vector<TensorImplPtr>&nullptr.outconst TensorImplPtr&save_insbool, default ``true``saved_inputs_v_ for use during backward.Returns
booltrue when the autograd graph was wired; false when grad mode is off or no input requires a gradient (no-op).
Notes
Side effects on success: derives dtype/device from the first
non-null input, records out_shape_, populates the per-input
vectors, records one Edge per input via
detail::ensure_grad_fn, captures versions, and marks
out as a non-leaf requires_grad tensor.
Methods
2Return the canonical schema name of the concrete op.
Verify no saved input was mutated in-place between forward and backward.
Notes
Iterates over the runtime input vector and calls
check_version_match on each, raising a clear error
(with the op name and slot index) if any version drifted.
Invoked by the autograd engine before apply.