Updates all e2e tests to use TracedModuleTestCase (#2736)
Follow up to #2660.
- Removes old infra:
- `CompiledModuleTestCase`
- `_VirtualModuleInstance`
- `_VirtualModuleFunctionWrapper`
- `_collect_disagreements_recursively`
- `_collect_disagreements`
- `_make_multi_result_class` and `MultiResults`
- `_instantiate_backends`
- `explicit_backend_test.py`
- Updates all tests in `integrations/tensorflow/e2e/` to use the `TracedModuleTestCase`.
- Updates `iree_e2e_test_suite` and `iree_vision_test_suite` to use the new explicit `--reference_backend` flag.
- Adds data generation helpers to `tf_utils`:
- `uniform(shape, dtype=np.float32)` reduces verbosity of getting random `np.float32` data.
- `ndarange(shape, dtype=np.float32)` reduces verbosity of generating high rank `np.arange` data.
- Updates `tf.tensor --> np.array` conversion in `TfCompiledModule` to handle the following case:
```python
a = np.array(31. dtype=np.float32)
b = tf.convert_to_tensor(a)
c = b.numpy()
type(a) != type(c) # np.array != np.float32
```
diff --git a/integrations/tensorflow/e2e/dynamic_mlp_test.py b/integrations/tensorflow/e2e/dynamic_mlp_test.py
index 72d7f1f..0b70e84 100644
--- a/integrations/tensorflow/e2e/dynamic_mlp_test.py
+++ b/integrations/tensorflow/e2e/dynamic_mlp_test.py
@@ -62,13 +62,15 @@
@tf_test_utils.compile_module(Mlp, exported_names=["predict"])
-class DynamicMlpTest(tf_test_utils.CompiledModuleTestCase):
+class DynamicMlpTest(tf_test_utils.TracedModuleTestCase):
def test_dynamic_batch(self):
- m = self.get_module()
- np.random.seed(12345)
- x = np.random.random([3, 28 * 28]).astype(np.float32) * 1e-3
- m.predict(x).print().assert_all_close()
+
+ def dynamic_batch(module):
+ x = tf_utils.uniform([3, 28 * 28]) * 1e-3
+ module.predict(x)
+
+ self.compare_backends(dynamic_batch)
if __name__ == "__main__":