Calculate the reverse-mode vector-Jacobian product for a function.
The return value is a tuple of [out, vjpFn], where out is the output of
f(primals), and vjpFn is a function that takes in cotangents for each
output and returns the cotangents for each input.
When { hasAux: true } is passed, the function f is expected to return an
[out, aux] tuple, and vjp returns [out, vjpFn, aux].
Calculate the reverse-mode vector-Jacobian product for a function.
The return value is a tuple of
[out, vjpFn], whereoutis the output off(primals), andvjpFnis a function that takes in cotangents for each output and returns the cotangents for each input.When
{ hasAux: true }is passed, the functionfis expected to return an[out, aux]tuple, andvjpreturns[out, vjpFn, aux].