latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.autograd.forward_ad.make_dual
- tensorplay.autograd.forward_ad.make_dual(tensor: Tensor, tangent: Tensor, *, level: int | None = None) Tensor[source]
Associates a tensor value with its tangent to create a “dual tensor”.
The result is a new tensor aliased to
tensorwithtangentattached as its forward gradient. The tangent can be recovered withunpack_dual().Given a function
fwhose jacobian isJ, this computes the Jacobian-vector product (jvp) betweenJand a given vectorv:>>> # xdoctest: +SKIP("Undefined variables") >>> with dual_level(): ... inp = make_dual(x, v) ... out = f(inp) ... y, jvp = unpack_dual(out)
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

