boundlab.diff.ops.diff_pair#

boundlab.diff.ops.diff_pair(x, y)[source]#

Mark x and y as the two branches of one differential value.

Exported as boundlab::DiffPair; the interpreter lifts that node into a DiffExpr2. Eagerly it is a no-op returning x, so a paired model still runs as network 1.

Parameters:
  • x (Tensor) – Tensor for the first network branch.

  • y (Tensor) – Tensor for the second branch; same shape and dtype as x.

Examples

>>> import torch
>>> from boundlab.diff.ops import diff_pair
>>> diff_pair(torch.zeros(4), torch.ones(4)).shape
torch.Size([4])