|
23 | 23 | from tensorflow_gnn.graph import graph_constants as const |
24 | 24 | from tensorflow_gnn.graph import graph_tensor as gt |
25 | 25 | 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 |
29 | 31 |
|
30 | 32 |
|
31 | 33 | class ReadoutTest(tf.test.TestCase, parameterized.TestCase): |
@@ -168,12 +170,11 @@ def testTFLite(self, location): |
168 | 170 | model = tf.keras.Model(inputs, outputs) |
169 | 171 | expected = model(test_graph_134_dict) |
170 | 172 |
|
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__}") |
175 | 173 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
176 | 174 | 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__}") |
177 | 178 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
178 | 179 | signature_runner = interpreter.get_signature_runner("serving_default") |
179 | 180 | obtained = signature_runner(**test_graph_134_dict)["test_readout"] |
@@ -303,11 +304,11 @@ def testTFLite(self): |
303 | 304 | expected = model(test_graph_22_dict) |
304 | 305 |
|
305 | 306 | # 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__}") |
309 | 307 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
310 | 308 | 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__}") |
311 | 312 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
312 | 313 | signature_runner = interpreter.get_signature_runner("serving_default") |
313 | 314 | obtained = signature_runner(**test_graph_22_dict)["test_readout_first"] |
@@ -435,6 +436,9 @@ def testTFLite(self): |
435 | 436 |
|
436 | 437 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
437 | 438 | 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__}") |
438 | 442 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
439 | 443 | signature_runner = interpreter.get_signature_runner("serving_default") |
440 | 444 | actual = signature_runner( |
@@ -569,6 +573,9 @@ def testTFLite(self): |
569 | 573 |
|
570 | 574 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
571 | 575 | 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__}") |
572 | 579 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
573 | 580 | signature_runner = interpreter.get_signature_runner("serving_default") |
574 | 581 | actual = signature_runner( |
@@ -632,6 +639,9 @@ def testTFLite(self): |
632 | 639 |
|
633 | 640 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
634 | 641 | 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__}") |
635 | 645 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
636 | 646 | signature_runner = interpreter.get_signature_runner("serving_default") |
637 | 647 | actual = signature_runner( |
@@ -748,12 +758,11 @@ def testTFLite(self): |
748 | 758 | model = tf.keras.Model(inputs, outputs) |
749 | 759 | expected = model(test_graph_134_dict).numpy() |
750 | 760 |
|
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__}") |
755 | 761 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
756 | 762 | 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__}") |
757 | 766 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
758 | 767 | signature_runner = interpreter.get_signature_runner("serving_default") |
759 | 768 | obtained = signature_runner(**test_graph_134_dict)["final_edge_states"] |
@@ -950,12 +959,11 @@ def testTFLite(self, tag, location): |
950 | 959 | model = tf.keras.Model(inputs, outputs) |
951 | 960 | expected = model(test_values) |
952 | 961 |
|
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__}") |
957 | 962 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
958 | 963 | 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__}") |
959 | 967 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
960 | 968 | signature_runner = interpreter.get_signature_runner("serving_default") |
961 | 969 | obtained = signature_runner(**test_values)["test_broadcast"] |
@@ -1258,12 +1266,11 @@ def testTFLite(self, tag, location, reduce_type): |
1258 | 1266 | model = tf.keras.Model(inputs, outputs) |
1259 | 1267 | expected = model(test_values) |
1260 | 1268 |
|
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__}") |
1265 | 1269 | converter = tf.lite.TFLiteConverter.from_keras_model(model) |
1266 | 1270 | 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__}") |
1267 | 1274 | interpreter = tfl_interpreter.Interpreter(model_content=model_content) |
1268 | 1275 | signature_runner = interpreter.get_signature_runner("serving_default") |
1269 | 1276 | obtained = signature_runner(**test_values)["test_pool"] |
|
0 commit comments