MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testStableSort

Method testStableSort

tensorflow/python/kernel_tests/topk_op_test.py:156–166  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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]]

Callers

nothing calls this directly

Calls 4

_validateTopKMethod · 0.95
reshapeMethod · 0.80
permutationMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected