mlx.core.jvp#
- jvp(fun: Callable, primals: list[array], tangents: list[array]) tuple[list[array], list[array]]#
Compute the Jacobian-vector product.
This computes the product of the Jacobian of a function
funevaluated atprimalswith thetangents.- Parameters:
fun (Callable) – A function which takes a variable number of
arrayand returns a singlearrayor list ofarray.primals (list(array)) – A list of
arrayat which to evaluate the Jacobian.tangents (list(array)) – A list of
arraywhich are the “vector” in the Jacobian-vector product. Thetangentsshould be the same in number, shape, and type as the inputs offun(i.e. theprimals).
- Returns:
A tuple with the outputs of
funin the first position and the Jacobian-vector products in the second position.- Return type:
Example
import mlx.core as mx outs, jvps = mx.jvp(mx.sin, (mx.array(1.0),), (mx.array(1.0),))