Tests that positive and negative zeros sort correctly.
(self)
| 128 | expected=[expected.astype(dtype), indices]) |
| 129 | |
| 130 | def testTopKZeros(self): |
| 131 | """Tests that positive and negative zeros sort correctly.""" |
| 132 | # Only bfloat16 is implemented. |
| 133 | bfloat16 = dtypes.bfloat16.as_numpy_dtype |
| 134 | if bfloat16 not in self.numeric_types: |
| 135 | return |
| 136 | |
| 137 | with self.session() as sess: |
| 138 | p = array_ops.placeholder(dtypes.bfloat16) |
| 139 | with self.test_scope(): |
| 140 | topk = nn_ops.top_k(p, k=4) |
| 141 | results = sess.run( |
| 142 | topk, |
| 143 | {p: np.array([0., -0., 0., 3., -0., -4., 0., -0.], dtype=bfloat16)}) |
| 144 | self.assertAllEqual( |
| 145 | np.array([3., 0., 0., 0.], dtype=bfloat16), results[0]) |
| 146 | self.assertEqual(list([3, 0, 2, 6]), list(results[1])) |
| 147 | |
| 148 | def testTopKInfinities(self): |
| 149 | """Tests that positive and negative infinity sort correctly.""" |
nothing calls this directly
no test coverage detected