(self)
| 154 | self._testMediumTopK(np.float16) |
| 155 | |
| 156 | def testStableSort(self): |
| 157 | b = 5 |
| 158 | n = 500 |
| 159 | for k in [1, 5, 50, 500]: |
| 160 | # Lots of repeated integers taking values in [0, 3] |
| 161 | inputs = np.random.permutation( |
| 162 | np.linspace(0, 3, b * n, dtype=np.int32)).reshape(b, n) |
| 163 | # Use mergesort, a stable sort, to get the indices. |
| 164 | indices = np.argsort(-inputs, axis=1, kind="mergesort")[:, :k] |
| 165 | values = -np.sort(-inputs, axis=1)[:, :k] |
| 166 | self._validateTopK(inputs, k, values, indices) |
| 167 | |
| 168 | def testTopAll(self): |
| 169 | inputs = [[0.1, 0.3, 0.2, 0.4], [0.1, 0.3, 0.3, 0.2]] |
nothing calls this directly
no test coverage detected