From ca567aba7ffb09afe1e56c98217f77df511aa5b5 Mon Sep 17 00:00:00 2001 From: "Salvetti, Francesco" Date: Fri, 30 Jun 2023 13:15:36 +0000 Subject: [PATCH] unique_with_counts test Signed-off-by: Salvetti, Francesco --- tests/test_backend.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/test_backend.py b/tests/test_backend.py index 99f89bb88..73d51251b 100755 --- a/tests/test_backend.py +++ b/tests/test_backend.py @@ -5011,6 +5011,39 @@ def func(x): y2 = tf.identity(x2_, name=_TFOUTPUT1) return y1, y2 self._run_test_case(func, [_OUTPUT, _OUTPUT1], {_INPUT: x_val}) + + @check_opset_min_version(11, "Unique") + def test_unique_with_counts(self): + x_val = np.array([1, 2, 8, 1, 2, 2, 7, 7, 7, 1], dtype=np.float32) + def func(x): + x1_, x2_, x3_ = tf.unique_with_counts(x) + y1 = tf.identity(x1_, name=_TFOUTPUT) + y2 = tf.identity(x2_, name=_TFOUTPUT1) + y3 = tf.identity(x3_, name=_TFOUTPUT2) + return y1, y2, y3 + self._run_test_case(func, [_OUTPUT, _OUTPUT1, _OUTPUT2], {_INPUT: x_val}) + + @check_opset_min_version(11, "Unique") + def test_unique_with_counts_out_int64(self): + x_val = np.array([2, 3, 3, 6, 4, 1, 1], dtype=np.float32) + def func(x): + x1_, x2_, x3_ = tf.unique_with_counts(x, out_idx=tf.int64) + y1 = tf.identity(x1_, name=_TFOUTPUT) + y2 = tf.identity(x2_, name=_TFOUTPUT1) + y3 = tf.identity(x3_, name=_TFOUTPUT2) + return y1, y2, y3 + self._run_test_case(func, [_OUTPUT, _OUTPUT1, _OUTPUT2], {_INPUT: x_val}) + + @check_opset_min_version(11, "Unique") + def test_unique_with_counts_out_int32(self): + x_val = np.array([2, 3, 3, 6, 4, 1, 1], dtype=np.float32) + def func(x): + x1_, x2_, x3_ = tf.unique(x, out_idx=tf.int32) + y1 = tf.identity(x1_, name=_TFOUTPUT) + y2 = tf.identity(x2_, name=_TFOUTPUT1) + y3 = tf.identity(x3_, name=_TFOUTPUT2) + return y1, y2, y3 + self._run_test_case(func, [_OUTPUT, _OUTPUT1, _OUTPUT2], {_INPUT: x_val}) @check_opset_min_version(11, "Unique") def test_bincount(self):