latest (dev)
Copy
Latest development documentation · Updated 2026-10-08
tensorplay.func.vjp
- tensorplay.func.vjp(func: Callable, *primals, has_aux: bool = False)
Evaluates
funcatprimalsand returns a function computing the vector-Jacobian product.- Parameters:
func (Callable) – a Python function taking one or more tensor arguments.
primals (Tensors) – positional arguments to evaluate
funcat. The returned function differentiates with respect to all of them.has_aux (bool) – whether
funcreturns(output, aux), whereauxis carried through undifferentiated.
- Returns:
(output, vjp_fn), or(output, vjp_fn, aux)whenhas_aux.vjp_fntakes a cotangent with the same structure asoutputand returns the gradients with respect toprimals.
Example
>>> x = tensorplay.randn(5) >>> out, vjp_fn = vjp(tensorplay.sin, x) >>> (grad,) = vjp_fn(tensorplay.ones_like(out))
Help improve this page
Found an error, an unclear step, or a missing example?
Was this page helpful?

