Skip to content

Commit f9b8f5c

Browse files
arnoegwtensorflower-gardener
authored andcommitted
Skip some tests that are broken with tf-nightly / ai-edge-litert-nightly.
Along the way, remove some skipTest calls for TF 2.10: the minimum required version has been TF2.12 for a long time now. PiperOrigin-RevId: 799138439
1 parent e3d0304 commit f9b8f5c

12 files changed

Lines changed: 125 additions & 83 deletions

File tree

tensorflow_gnn/graph/graph_tensor_ops_test.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
from tensorflow_gnn.graph import graph_tensor_ops as ops
2626
from tensorflow_gnn.graph import pool_ops
2727
from tensorflow_gnn.graph import readout
28-
# pylint: disable=g-direct-tensorflow-import
29-
from ai_edge_litert import interpreter as tfl_interpreter
30-
# pylint: enable=g-direct-tensorflow-import
28+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
29+
if not tf.__version__.startswith('2.20.'): # TODO: b/441006328 - Remove this.
30+
# The following import crashes with tf-nightly~=2.20.0.
31+
from ai_edge_litert import interpreter as tfl_interpreter
32+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
3133

3234
as_tensor = tf.convert_to_tensor
3335
as_ragged = tf.ragged.constant
@@ -639,12 +641,11 @@ def testTFLite(self):
639641
model = tf.keras.Model(inputs, outputs)
640642
expected = model(test_graph_dict).numpy()
641643

642-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
643-
if tf.__version__.startswith('2.10.'):
644-
self.skipTest('GNN models are unsupported in TFLite until TF 2.11 but '
645-
f'got TF {tf.__version__}')
646644
converter = tf.lite.TFLiteConverter.from_keras_model(model)
647645
model_content = converter.convert()
646+
if tf.__version__.startswith('2.20.'):
647+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
648+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
648649
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
649650
signature_runner = interpreter.get_signature_runner('serving_default')
650651
obtained = signature_runner(**test_graph_dict)['final_edge_adjacency']
@@ -1305,12 +1306,11 @@ def testTFLite(self):
13051306
model = tf.keras.Model(inputs, outputs)
13061307
expected = model(test_graph_dict).numpy()
13071308

1308-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
1309-
if tf.__version__.startswith('2.10.'):
1310-
self.skipTest('GNN models are unsupported in TFLite until TF 2.11 but '
1311-
f'got TF {tf.__version__}')
13121309
converter = tf.lite.TFLiteConverter.from_keras_model(model)
13131310
model_content = converter.convert()
1311+
if tf.__version__.startswith('2.20.'):
1312+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
1313+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
13141314
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
13151315
signature_runner = interpreter.get_signature_runner('serving_default')
13161316
obtained = signature_runner(**test_graph_dict)['final_edge_adjacency']
@@ -1677,12 +1677,11 @@ def testTFLite(self):
16771677
model = tf.keras.Model(inputs, outputs)
16781678
expected = model(test_graph_dict).numpy()
16791679

1680-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
1681-
if tf.__version__.startswith('2.10.'):
1682-
self.skipTest('GNN models are unsupported in TFLite until TF 2.11 but '
1683-
f'got TF {tf.__version__}')
16841680
converter = tf.lite.TFLiteConverter.from_keras_model(model)
16851681
model_content = converter.convert()
1682+
if tf.__version__.startswith('2.20.'):
1683+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
1684+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
16861685
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
16871686
signature_runner = interpreter.get_signature_runner('serving_default')
16881687
obtained = signature_runner(**test_graph_dict)['final_edge_adjacency']

tensorflow_gnn/graph/graph_tensor_test.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
from tensorflow_gnn.graph import graph_tensor as gt
2525
from tensorflow_gnn.graph import graph_tensor_test_utils as tu
2626

27-
# pylint: disable=g-direct-tensorflow-import
28-
from ai_edge_litert import interpreter as tfl_interpreter
27+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
28+
if not tf.__version__.startswith('2.20.'): # TODO: b/441006328 - Remove this.
29+
# The following import crashes with tf-nightly~=2.20.0.
30+
from ai_edge_litert import interpreter as tfl_interpreter
2931
from tensorflow.python.framework import type_spec
30-
# pylint: enable=g-direct-tensorflow-import
32+
# pylint: enable=g-import-not-at-top,g-direct-tensorflow-import
3133

3234
as_tensor = tf.convert_to_tensor
3335
as_ragged = tf.ragged.constant
@@ -1544,12 +1546,11 @@ def testTFLite(self):
15441546
# The other unit tests should verify that this is correct
15451547
expected = [0, 1, 2]
15461548

1547-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
1548-
if tf.__version__.startswith('2.10.'):
1549-
self.skipTest('GNN models are unsupported in TFLite until TF 2.11 but '
1550-
f'got TF {tf.__version__}')
15511549
converter = tf.lite.TFLiteConverter.from_keras_model(model)
15521550
model_content = converter.convert()
1551+
if tf.__version__.startswith('2.20.'):
1552+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
1553+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
15531554
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
15541555
signature_runner = interpreter.get_signature_runner('serving_default')
15551556
obtained = signature_runner(
@@ -1753,6 +1754,9 @@ def testTFLite(self):
17531754

17541755
converter = tf.lite.TFLiteConverter.from_keras_model(model)
17551756
model_content = converter.convert()
1757+
if tf.__version__.startswith('2.20.'):
1758+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
1759+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
17561760
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
17571761
signature_runner = interpreter.get_signature_runner('serving_default')
17581762
obtained = signature_runner(

tensorflow_gnn/keras/layers/graph_ops_test.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
from tensorflow_gnn.graph import graph_constants as const
2424
from tensorflow_gnn.graph import graph_tensor as gt
2525
from tensorflow_gnn.keras.layers import graph_ops
26-
# pylint: disable=g-direct-tensorflow-import
27-
from ai_edge_litert import interpreter as tfl_interpreter
28-
# pylint: enable=g-direct-tensorflow-import
26+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
27+
if not tf.__version__.startswith("2.20."): # TODO: b/441006328 - Remove this.
28+
# The following import crashes with tf-nightly~=2.20.0.
29+
from ai_edge_litert import interpreter as tfl_interpreter
30+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2931

3032

3133
class ReadoutTest(tf.test.TestCase, parameterized.TestCase):
@@ -168,12 +170,11 @@ def testTFLite(self, location):
168170
model = tf.keras.Model(inputs, outputs)
169171
expected = model(test_graph_134_dict)
170172

171-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
172-
if tf.__version__.startswith("2.10."):
173-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
174-
f"got TF {tf.__version__}")
175173
converter = tf.lite.TFLiteConverter.from_keras_model(model)
176174
model_content = converter.convert()
175+
if tf.__version__.startswith("2.20."):
176+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
177+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
177178
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
178179
signature_runner = interpreter.get_signature_runner("serving_default")
179180
obtained = signature_runner(**test_graph_134_dict)["test_readout"]
@@ -303,11 +304,11 @@ def testTFLite(self):
303304
expected = model(test_graph_22_dict)
304305

305306
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
306-
if tf.__version__.startswith("2.10."):
307-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
308-
f"got TF {tf.__version__}")
309307
converter = tf.lite.TFLiteConverter.from_keras_model(model)
310308
model_content = converter.convert()
309+
if tf.__version__.startswith("2.20."):
310+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
311+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
311312
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
312313
signature_runner = interpreter.get_signature_runner("serving_default")
313314
obtained = signature_runner(**test_graph_22_dict)["test_readout_first"]
@@ -435,6 +436,9 @@ def testTFLite(self):
435436

436437
converter = tf.lite.TFLiteConverter.from_keras_model(model)
437438
model_content = converter.convert()
439+
if tf.__version__.startswith("2.20."):
440+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
441+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
438442
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
439443
signature_runner = interpreter.get_signature_runner("serving_default")
440444
actual = signature_runner(
@@ -569,6 +573,9 @@ def testTFLite(self):
569573

570574
converter = tf.lite.TFLiteConverter.from_keras_model(model)
571575
model_content = converter.convert()
576+
if tf.__version__.startswith("2.20."):
577+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
578+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
572579
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
573580
signature_runner = interpreter.get_signature_runner("serving_default")
574581
actual = signature_runner(
@@ -632,6 +639,9 @@ def testTFLite(self):
632639

633640
converter = tf.lite.TFLiteConverter.from_keras_model(model)
634641
model_content = converter.convert()
642+
if tf.__version__.startswith("2.20."):
643+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
644+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
635645
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
636646
signature_runner = interpreter.get_signature_runner("serving_default")
637647
actual = signature_runner(
@@ -748,12 +758,11 @@ def testTFLite(self):
748758
model = tf.keras.Model(inputs, outputs)
749759
expected = model(test_graph_134_dict).numpy()
750760

751-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
752-
if tf.__version__.startswith("2.10."):
753-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
754-
f"got TF {tf.__version__}")
755761
converter = tf.lite.TFLiteConverter.from_keras_model(model)
756762
model_content = converter.convert()
763+
if tf.__version__.startswith("2.20."):
764+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
765+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
757766
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
758767
signature_runner = interpreter.get_signature_runner("serving_default")
759768
obtained = signature_runner(**test_graph_134_dict)["final_edge_states"]
@@ -950,12 +959,11 @@ def testTFLite(self, tag, location):
950959
model = tf.keras.Model(inputs, outputs)
951960
expected = model(test_values)
952961

953-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
954-
if tf.__version__.startswith("2.10."):
955-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
956-
f"got TF {tf.__version__}")
957962
converter = tf.lite.TFLiteConverter.from_keras_model(model)
958963
model_content = converter.convert()
964+
if tf.__version__.startswith("2.20."):
965+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
966+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
959967
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
960968
signature_runner = interpreter.get_signature_runner("serving_default")
961969
obtained = signature_runner(**test_values)["test_broadcast"]
@@ -1258,12 +1266,11 @@ def testTFLite(self, tag, location, reduce_type):
12581266
model = tf.keras.Model(inputs, outputs)
12591267
expected = model(test_values)
12601268

1261-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
1262-
if tf.__version__.startswith("2.10."):
1263-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
1264-
f"got TF {tf.__version__}")
12651269
converter = tf.lite.TFLiteConverter.from_keras_model(model)
12661270
model_content = converter.convert()
1271+
if tf.__version__.startswith("2.20."):
1272+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
1273+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
12671274
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
12681275
signature_runner = interpreter.get_signature_runner("serving_default")
12691276
obtained = signature_runner(**test_values)["test_pool"]

tensorflow_gnn/keras/layers/next_state_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
from tensorflow_gnn.graph import graph_constants as const
2020
from tensorflow_gnn.keras.layers import next_state as next_state_lib
2121
from tensorflow_gnn.utils import tf_test_utils as tftu
22-
# pylint: disable=g-direct-tensorflow-import
23-
from ai_edge_litert import interpreter as tfl_interpreter
24-
# pylint: enable=g-direct-tensorflow-import
22+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
23+
if not tf.__version__.startswith("2.20."): # TODO: b/441006328 - Remove this.
24+
# The following import crashes with tf-nightly~=2.20.0.
25+
from ai_edge_litert import interpreter as tfl_interpreter
26+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2527

2628

2729
class NextStateFromConcatTest(tf.test.TestCase, parameterized.TestCase):
@@ -182,6 +184,9 @@ def testTFLite(self):
182184

183185
converter = tf.lite.TFLiteConverter.from_keras_model(model)
184186
model_content = converter.convert()
187+
if tf.__version__.startswith("2.20."):
188+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
189+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
185190
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
186191
signature_runner = interpreter.get_signature_runner("serving_default")
187192
obtained = signature_runner(**test_input_dict)["residual_next_state"]

tensorflow_gnn/keras/layers/padding_ops_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
from tensorflow_gnn.keras import keras_tensors # For registration. pylint: disable=unused-import
2424
from tensorflow_gnn.keras.layers import padding_ops
2525
from tensorflow_gnn.utils import tf_test_utils as tftu
26-
# pylint: disable=g-direct-tensorflow-import
27-
from ai_edge_litert import interpreter as tfl_interpreter
28-
# pylint: enable=g-direct-tensorflow-import
26+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
27+
if not tf.__version__.startswith("2.20."): # TODO: b/441006328 - Remove this.
28+
# The following import crashes with tf-nightly~=2.20.0.
29+
from ai_edge_litert import interpreter as tfl_interpreter
30+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2931

3032

3133
class PadToTotalSizesTest(tf.test.TestCase, parameterized.TestCase):

tensorflow_gnn/models/gat_v2/layers_test.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
import tensorflow_gnn as tfgnn
1818
from tensorflow_gnn.models import gat_v2
1919
from tensorflow_gnn.utils import tf_test_utils as tftu
20-
# pylint: disable=g-direct-tensorflow-import
21-
from ai_edge_litert import interpreter as tfl_interpreter
22-
# pylint: enable=g-direct-tensorflow-import
20+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
21+
if not tf.__version__.startswith("2.20."): # TODO: b/441006328 - Remove this.
22+
# The following import crashes with tf-nightly~=2.20.0.
23+
from ai_edge_litert import interpreter as tfl_interpreter
24+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2325

2426

2527
class GATv2Test(tf.test.TestCase, parameterized.TestCase):
@@ -199,6 +201,8 @@ def testMultihead(self, merge_type):
199201
want = tf.nn.relu((want_logits[:, :4] + want_logits[:, 4:]) / 2)
200202
elif merge_type == "concat":
201203
want = tf.nn.relu(want_logits)
204+
else:
205+
raise AssertionError(f"Bad test set-up: unknown merge_type {merge_type}")
202206

203207
self.assertAllClose(got, want, atol=0.0001)
204208

@@ -701,12 +705,11 @@ def testBasic(self):
701705
# The other unit tests should verify that this is correct
702706
expected = model(test_graph_1_dict).numpy()
703707

704-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
705-
if tf.__version__.startswith("2.10."):
706-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
707-
f"got TF {tf.__version__}")
708708
converter = tf.lite.TFLiteConverter.from_keras_model(model)
709709
model_content = converter.convert()
710+
if tf.__version__.startswith("2.20."):
711+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
712+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
710713
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
711714
signature_runner = interpreter.get_signature_runner("serving_default")
712715
obtained = signature_runner(**test_graph_1_dict)["final_node_states"]

tensorflow_gnn/models/gcn/gcn_conv_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import tensorflow_gnn as tfgnn
2020
from tensorflow_gnn.models.gcn import gcn_conv
2121
from tensorflow_gnn.utils import tf_test_utils as tftu
22-
# pylint: disable=g-direct-tensorflow-import
23-
from ai_edge_litert import interpreter as tfl_interpreter
24-
# pylint: enable=g-direct-tensorflow-import
22+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
23+
if not tf.__version__.startswith('2.20.'): # TODO: b/441006328 - Remove this.
24+
# The following import crashes with tf-nightly~=2.20.0.
25+
from ai_edge_litert import interpreter as tfl_interpreter
26+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2527

2628

2729
class GcnConvTest(tf.test.TestCase, parameterized.TestCase):
@@ -869,12 +871,11 @@ def testBasic(self, add_self_loops, edge_weight_feature_name):
869871
# The other unit tests should verify that this is correct
870872
expected = model(test_graph_1_dict).numpy()
871873

872-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
873-
if tf.__version__.startswith('2.10.'):
874-
self.skipTest('GNN models are unsupported in TFLite until TF 2.11 but '
875-
f'got TF {tf.__version__}')
876874
converter = tf.lite.TFLiteConverter.from_keras_model(model)
877875
model_content = converter.convert()
876+
if tf.__version__.startswith('2.20.'):
877+
self.skipTest('TODO: b/441006328 - tfl_interpreter cannot be imported '
878+
f'next to tf-nightly~=2.20.0; got TF {tf.__version__}')
878879
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
879880
signature_runner = interpreter.get_signature_runner('serving_default')
880881
obtained = signature_runner(**test_graph_1_dict)['final_node_states']

tensorflow_gnn/models/graph_sage/layers_test.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import tensorflow_gnn as tfgnn
2020
from tensorflow_gnn.models.graph_sage import layers as graph_sage
2121
from tensorflow_gnn.utils import tf_test_utils as tftu
22-
# pylint: disable=g-direct-tensorflow-import
23-
from ai_edge_litert import interpreter as tfl_interpreter
24-
# pylint: enable=g-direct-tensorflow-import
22+
# pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
23+
if not tf.__version__.startswith("2.20."): # TODO: b/441006328 - Remove this.
24+
# The following import crashes with tf-nightly~=2.20.0.
25+
from ai_edge_litert import interpreter as tfl_interpreter
26+
# pylint: enable=g-direct-tensorflow-import,g-import-not-at-top
2527

2628
_FEATURE_NAME = "f"
2729

@@ -620,12 +622,11 @@ def testBasic(self, use_pooling, hidden_units, combine_type):
620622
# The other unit tests should verify that this is correct
621623
expected = model(test_graph_1_dict).numpy()
622624

623-
# TODO(b/276291104): Remove when TF 2.11+ is required by all of TFGNN
624-
if tf.__version__.startswith("2.10."):
625-
self.skipTest("GNN models are unsupported in TFLite until TF 2.11 but "
626-
f"got TF {tf.__version__}")
627625
converter = tf.lite.TFLiteConverter.from_keras_model(model)
628626
model_content = converter.convert()
627+
if tf.__version__.startswith("2.20."):
628+
self.skipTest("TODO: b/441006328 - tfl_interpreter cannot be imported "
629+
f"next to tf-nightly~=2.20.0; got TF {tf.__version__}")
629630
interpreter = tfl_interpreter.Interpreter(model_content=model_content)
630631
signature_runner = interpreter.get_signature_runner("serving_default")
631632
obtained = signature_runner(**test_graph_1_dict)["final_node_states"]

0 commit comments

Comments
 (0)