Add unit test: testNoEmptyRowsAndUnordered
Add unit test for `SparseFillEmptyRows`: When the sp_input is unordered and all rows of the sp_input are not empty, the output of `tf.sparse.fill_empty_rows` is still ordered.
This commit is contained in:
parent
277cb88cf6
commit
c79fbeed1a
@ -585,6 +585,22 @@ class SparseFillEmptyRowsTest(test_util.TensorFlowTestCase):
|
|||||||
self.assertAllEqual(output.dense_shape, [2, 6])
|
self.assertAllEqual(output.dense_shape, [2, 6])
|
||||||
self.assertAllEqual(empty_row_indicator_out, np.zeros(2).astype(np.bool))
|
self.assertAllEqual(empty_row_indicator_out, np.zeros(2).astype(np.bool))
|
||||||
|
|
||||||
|
def testNoEmptyRowsAndUnordered(self):
|
||||||
|
with test_util.force_cpu():
|
||||||
|
sp_input = sparse_tensor.SparseTensor(
|
||||||
|
indices=np.array([[1, 2], [1, 3], [0, 1], [0, 3]]),
|
||||||
|
values=np.array([1, 3, 2, 4]),
|
||||||
|
dense_shape=np.array([2, 5]))
|
||||||
|
sp_output, empty_row_indicator = (sparse_ops.sparse_fill_empty_rows(
|
||||||
|
sp_input, -1))
|
||||||
|
|
||||||
|
output, empty_row_indicator_out = self.evaluate(
|
||||||
|
[sp_output, empty_row_indicator])
|
||||||
|
|
||||||
|
self.assertAllEqual(output.indices, [[0, 1], [0, 3], [1, 2], [1, 3]])
|
||||||
|
self.assertAllEqual(output.values, [2, 4, 1, 3])
|
||||||
|
self.assertAllEqual(output.dense_shape, [2, 5])
|
||||||
|
self.assertAllEqual(empty_row_indicator_out, np.zeros(2).astype(np.bool))
|
||||||
|
|
||||||
class SparseAddTest(test_util.TensorFlowTestCase):
|
class SparseAddTest(test_util.TensorFlowTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user