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)
| 505 | return o.reshape(quaternions.shape[:-1] + (3, 3)) |
| 506 | |
| 507 | def _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 |
no outgoing calls
no test coverage detected