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

Method testTopKZeros

tensorflow/compiler/tests/sort_ops_test.py:130–146  ·  view source on GitHub ↗

Tests that positive and negative zeros sort correctly.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 5

sessionMethod · 0.45
placeholderMethod · 0.45
test_scopeMethod · 0.45
runMethod · 0.45
assertAllEqualMethod · 0.45

Tested by

no test coverage detected