Number of representable bf16 points between each item in x and y.
(x: np.ndarray, y: np.ndarray)
| 1723 | |
| 1724 | |
| 1725 | def _bfloat16_nulp_diff(x: np.ndarray, y: np.ndarray) -> np.ndarray: |
| 1726 | """Number of representable bf16 points between each item in x and y.""" |
| 1727 | rx = x.view(np.int16) |
| 1728 | ry = y.view(np.int16) |
| 1729 | # The constant for two's complement adjustment, same as for float16. |
| 1730 | comp = np.int16(-(2**15)) |
| 1731 | # Transform the integer representations of negative numbers, to make the |
| 1732 | # integer representation monotonic across the full range of floats. |
| 1733 | rx = np.where(rx < 0, comp - rx, rx) |
| 1734 | ry = np.where(ry < 0, comp - ry, ry) |
| 1735 | diff = np.abs(rx.astype(np.int32) - ry.astype(np.int32)) |
| 1736 | return diff.astype(np.float64) |
| 1737 | |
| 1738 | |
| 1739 | def _assert_trees_all_close_ulp_static( |
no outgoing calls
no test coverage detected
searching dependent graphs…