Function torch::autograd::create_gradient_edge#
Defined in File function.h
Function Documentation#
Create an
Edgebetween the givenvariableand 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_fnproperty of thevariable. This function assumes that theVariableis a new input to the gradient function and itsinput_nrthus 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_inputsto be incremented, useset_gradient_edgedirectly.