Function torch::autograd::create_gradient_edge¶
Defined in File function.h
Function Documentation¶
Create an
Edge
between the givenvariable
and thefunction
, which is assumed to be the gradient function of this variable (i.e.the function through which this variable is backpropagated during the backward pass). This sets the
grad_fn
property of thevariable
. This function assumes that theVariable
is a new input to the gradient function and itsinput_nr
thus equal tofunction->num_inputs()
. Additionally, it increments theNode
’s number of inputs by one. Approximately equivalent tovariable.set_gradient_edge(function, function->add_input_metadata(variable.dispatch_type(), variable.sizes()))
. If you don’t want theNode
’snum_inputs
to be incremented, useset_gradient_edge
directly.