MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / _copysign

Function _copysign

utils/general_util.py:507–522  ·  view source on GitHub ↗

Return a tensor where each element has the absolute value taken from the, corresponding element of a, with sign taken from the corresponding element of b. This is like the standard copysign floating-point operation, but is not careful about negative 0 and NaN. Args: a:

(a: torch.Tensor, b: torch.Tensor)

Source from the content-addressed store, hash-verified

505 return o.reshape(quaternions.shape[:-1] + (3, 3))
506
507def _copysign(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor:
508 """
509 Return a tensor where each element has the absolute value taken from the,
510 corresponding element of a, with sign taken from the corresponding
511 element of b. This is like the standard copysign floating-point operation,
512 but is not careful about negative 0 and NaN.
513
514 Args:
515 a: source tensor.
516 b: tensor whose signs will be used, of the same shape as a.
517
518 Returns:
519 Tensor of the same shape as a with the signs of b.
520 """
521 signs_differ = (a < 0) != (b < 0)
522 return torch.where(signs_differ, -a, a)
523
524
525

Callers 1

random_quaternionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected