MCPcopy Create free account
hub / github.com/pytorch/tutorials / hvp_revrev

Function hvp_revrev

intermediate_source/jacobians_hessians.py:344–346  ·  view source on GitHub ↗
(f, primals, tangents)

Source from the content-addressed store, hash-verified

342# instead compose reverse-mode AD with reverse-mode AD:
343
344def hvp_revrev(f, primals, tangents):
345 _, vjp_fn = vjp(grad(f), *primals)
346 return vjp_fn(*tangents)
347
348result_hvp_revrev = hvp_revrev(f, (x,), (tangent,))
349assert torch.allclose(result, result_hvp_revrev[0])

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected