From fe1e2d8fdd0fa96565793f532b944efd0497c43e Mon Sep 17 00:00:00 2001 From: Yanhui Liang Date: Mon, 3 Feb 2020 17:25:54 -0800 Subject: [PATCH] Re-organize Keras integration tests. PiperOrigin-RevId: 293043030 Change-Id: I81c95911434a207110abc7895813c4b14ed297e0 --- tensorflow/python/keras/BUILD | 108 -------------- tensorflow/python/keras/saving/BUILD | 13 -- tensorflow/python/keras/tests/BUILD | 138 ++++++++++++++++++ .../{ => tests}/add_loss_correctness_test.py | 0 .../{ => tests}/custom_training_loop_test.py | 0 .../keras/{ => tests}/integration_test.py | 0 .../{saving => tests}/model_architectures.py | 0 .../model_architectures_test.py} | 2 +- .../model_subclassing_compiled_test.py | 2 +- .../{ => tests}/model_subclassing_test.py | 2 +- .../model_subclassing_test_util.py | 0 ...emporal_sample_weights_correctness_test.py | 0 tensorflow/tools/pip_package/BUILD | 3 +- 13 files changed, 143 insertions(+), 125 deletions(-) create mode 100644 tensorflow/python/keras/tests/BUILD rename tensorflow/python/keras/{ => tests}/add_loss_correctness_test.py (100%) rename tensorflow/python/keras/{ => tests}/custom_training_loop_test.py (100%) rename tensorflow/python/keras/{ => tests}/integration_test.py (100%) rename tensorflow/python/keras/{saving => tests}/model_architectures.py (100%) rename tensorflow/python/keras/{saving/save_model_architecture_test.py => tests/model_architectures_test.py} (98%) rename tensorflow/python/keras/{ => tests}/model_subclassing_compiled_test.py (99%) rename tensorflow/python/keras/{ => tests}/model_subclassing_test.py (99%) rename tensorflow/python/keras/{ => tests}/model_subclassing_test_util.py (100%) rename tensorflow/python/keras/{ => tests}/temporal_sample_weights_correctness_test.py (100%) diff --git a/tensorflow/python/keras/BUILD b/tensorflow/python/keras/BUILD index 8711e52e94a..7c89061ab2c 100755 --- a/tensorflow/python/keras/BUILD +++ b/tensorflow/python/keras/BUILD @@ -279,25 +279,6 @@ py_library( ], ) -tf_py_test( - name = "integration_test", - size = "medium", - srcs = ["integration_test.py"], - python_version = "PY3", - shard_count = 16, - tags = [ - "no_rocm", - "notsan", - ], - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//tensorflow/python:nn_ops", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - tf_py_test( name = "activations_test", size = "small", @@ -380,20 +361,6 @@ tf_py_test( ], ) -tf_py_test( - name = "add_loss_correctness_test", - size = "medium", - srcs = ["add_loss_correctness_test.py"], - python_version = "PY3", - shard_count = 4, - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - tf_py_test( name = "metrics_functional_test", size = "small", @@ -448,19 +415,6 @@ tf_py_test( ], ) -tf_py_test( - name = "temporal_sample_weights_correctness_test", - size = "medium", - srcs = ["temporal_sample_weights_correctness_test.py"], - python_version = "PY3", - shard_count = 20, - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - ], -) - tf_py_test( name = "callbacks_test", size = "medium", @@ -494,68 +448,6 @@ tf_py_test( ], ) -py_library( - name = "model_subclassing_test_util", - srcs = ["model_subclassing_test_util.py"], - srcs_version = "PY2AND3", - deps = [ - ":keras", - ], -) - -tf_py_test( - name = "model_subclassing_test", - size = "medium", - srcs = ["model_subclassing_test.py"], - python_version = "PY3", - shard_count = 4, - tags = [ - "no_windows", - "notsan", - ], - deps = [ - ":keras", - ":model_subclassing_test_util", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - -tf_py_test( - name = "model_subclassing_compiled_test", - size = "medium", - srcs = ["model_subclassing_compiled_test.py"], - python_version = "PY3", - shard_count = 4, - tags = [ - "no_windows", - "notsan", - ], - deps = [ - ":keras", - ":model_subclassing_test_util", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - -tf_py_test( - name = "custom_training_loop_test", - size = "medium", - srcs = ["custom_training_loop_test.py"], - python_version = "PY3", - shard_count = 4, - tags = ["notsan"], - deps = [ - ":keras", - "//tensorflow/python:client_testlib", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - tf_py_test( name = "models_test", size = "medium", diff --git a/tensorflow/python/keras/saving/BUILD b/tensorflow/python/keras/saving/BUILD index 0e9cf55b24b..3a4bca18e40 100644 --- a/tensorflow/python/keras/saving/BUILD +++ b/tensorflow/python/keras/saving/BUILD @@ -15,7 +15,6 @@ py_library( srcs = [ "__init__.py", "hdf5_format.py", - "model_architectures.py", "model_config.py", "save.py", "saved_model/base_serialization.py", @@ -50,18 +49,6 @@ py_library( ], ) -tf_py_test( - name = "save_model_architecture_test", - srcs = ["save_model_architecture_test.py"], - python_version = "PY3", - shard_count = 16, - deps = [ - "//tensorflow/python/keras", - "//third_party/py/numpy", - "@absl_py//absl/testing:parameterized", - ], -) - tf_py_test( name = "metrics_serialization_test", size = "medium", diff --git a/tensorflow/python/keras/tests/BUILD b/tensorflow/python/keras/tests/BUILD new file mode 100644 index 00000000000..fe339380d01 --- /dev/null +++ b/tensorflow/python/keras/tests/BUILD @@ -0,0 +1,138 @@ +# Description: +# Contains Keras test utils and integration tests. + +load("//tensorflow:tensorflow.bzl", "tf_py_test") + +package( + default_visibility = ["//visibility:public"], + licenses = ["notice"], # Apache 2.0 +) + +exports_files(["LICENSE"]) + +tf_py_test( + name = "add_loss_correctness_test", + srcs = ["add_loss_correctness_test.py"], + python_version = "PY3", + shard_count = 4, + deps = [ + "//tensorflow/python:client_testlib", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +tf_py_test( + name = "custom_training_loop_test", + srcs = ["custom_training_loop_test.py"], + python_version = "PY3", + shard_count = 4, + tags = ["notsan"], + deps = [ + "//tensorflow/python:client_testlib", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +tf_py_test( + name = "integration_test", + size = "medium", + srcs = ["integration_test.py"], + python_version = "PY3", + shard_count = 16, + tags = [ + "no_rocm", + "notsan", + ], + deps = [ + "//tensorflow/python:client_testlib", + "//tensorflow/python:nn_ops", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +py_library( + name = "model_architectures", + srcs = [ + "model_architectures.py", + ], + srcs_version = "PY2AND3", + deps = [ + "//tensorflow/python/keras", + ], +) + +tf_py_test( + name = "model_architectures_test", + srcs = ["model_architectures_test.py"], + python_version = "PY3", + shard_count = 16, + deps = [ + ":model_architectures", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +py_library( + name = "model_subclassing_test_util", + srcs = ["model_subclassing_test_util.py"], + srcs_version = "PY2AND3", + deps = [ + "//tensorflow/python/keras", + ], +) + +tf_py_test( + name = "model_subclassing_test", + srcs = ["model_subclassing_test.py"], + python_version = "PY3", + shard_count = 4, + tags = [ + "no_windows", + "notsan", + ], + deps = [ + ":model_subclassing_test_util", + "//tensorflow/python:client_testlib", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +tf_py_test( + name = "model_subclassing_compiled_test", + srcs = ["model_subclassing_compiled_test.py"], + python_version = "PY3", + shard_count = 4, + tags = [ + "no_windows", + "notsan", + ], + deps = [ + ":model_subclassing_test_util", + "//tensorflow/python:client_testlib", + "//tensorflow/python/keras", + "//third_party/py/numpy", + "@absl_py//absl/testing:parameterized", + ], +) + +tf_py_test( + name = "temporal_sample_weights_correctness_test", + srcs = ["temporal_sample_weights_correctness_test.py"], + python_version = "PY3", + shard_count = 20, + deps = [ + "//tensorflow/python:client_testlib", + "//tensorflow/python/keras", + "//third_party/py/numpy", + ], +) diff --git a/tensorflow/python/keras/add_loss_correctness_test.py b/tensorflow/python/keras/tests/add_loss_correctness_test.py similarity index 100% rename from tensorflow/python/keras/add_loss_correctness_test.py rename to tensorflow/python/keras/tests/add_loss_correctness_test.py diff --git a/tensorflow/python/keras/custom_training_loop_test.py b/tensorflow/python/keras/tests/custom_training_loop_test.py similarity index 100% rename from tensorflow/python/keras/custom_training_loop_test.py rename to tensorflow/python/keras/tests/custom_training_loop_test.py diff --git a/tensorflow/python/keras/integration_test.py b/tensorflow/python/keras/tests/integration_test.py similarity index 100% rename from tensorflow/python/keras/integration_test.py rename to tensorflow/python/keras/tests/integration_test.py diff --git a/tensorflow/python/keras/saving/model_architectures.py b/tensorflow/python/keras/tests/model_architectures.py similarity index 100% rename from tensorflow/python/keras/saving/model_architectures.py rename to tensorflow/python/keras/tests/model_architectures.py diff --git a/tensorflow/python/keras/saving/save_model_architecture_test.py b/tensorflow/python/keras/tests/model_architectures_test.py similarity index 98% rename from tensorflow/python/keras/saving/save_model_architecture_test.py rename to tensorflow/python/keras/tests/model_architectures_test.py index c16c0c3b1ee..387ed97da83 100644 --- a/tensorflow/python/keras/saving/save_model_architecture_test.py +++ b/tensorflow/python/keras/tests/model_architectures_test.py @@ -27,7 +27,7 @@ import numpy as np from tensorflow.python import keras from tensorflow.python.keras import keras_parameterized from tensorflow.python.keras import testing_utils -from tensorflow.python.keras.saving import model_architectures +from tensorflow.python.keras.tests import model_architectures from tensorflow.python.platform import test diff --git a/tensorflow/python/keras/model_subclassing_compiled_test.py b/tensorflow/python/keras/tests/model_subclassing_compiled_test.py similarity index 99% rename from tensorflow/python/keras/model_subclassing_compiled_test.py rename to tensorflow/python/keras/tests/model_subclassing_compiled_test.py index 18cb6e50980..404c9f0c975 100644 --- a/tensorflow/python/keras/model_subclassing_compiled_test.py +++ b/tensorflow/python/keras/tests/model_subclassing_compiled_test.py @@ -25,8 +25,8 @@ import numpy as np from tensorflow.python import keras from tensorflow.python.data.ops import dataset_ops from tensorflow.python.keras import keras_parameterized -from tensorflow.python.keras import model_subclassing_test_util as model_util from tensorflow.python.keras import testing_utils +from tensorflow.python.keras.tests import model_subclassing_test_util as model_util from tensorflow.python.platform import test try: diff --git a/tensorflow/python/keras/model_subclassing_test.py b/tensorflow/python/keras/tests/model_subclassing_test.py similarity index 99% rename from tensorflow/python/keras/model_subclassing_test.py rename to tensorflow/python/keras/tests/model_subclassing_test.py index 5202b44c3a8..755afc18ca8 100644 --- a/tensorflow/python/keras/model_subclassing_test.py +++ b/tensorflow/python/keras/tests/model_subclassing_test.py @@ -30,8 +30,8 @@ from tensorflow.python.framework import ops from tensorflow.python.framework import tensor_shape from tensorflow.python.framework import test_util from tensorflow.python.keras import keras_parameterized -from tensorflow.python.keras import model_subclassing_test_util as model_util from tensorflow.python.keras import testing_utils +from tensorflow.python.keras.tests import model_subclassing_test_util as model_util from tensorflow.python.ops import array_ops from tensorflow.python.ops import embedding_ops from tensorflow.python.ops import init_ops diff --git a/tensorflow/python/keras/model_subclassing_test_util.py b/tensorflow/python/keras/tests/model_subclassing_test_util.py similarity index 100% rename from tensorflow/python/keras/model_subclassing_test_util.py rename to tensorflow/python/keras/tests/model_subclassing_test_util.py diff --git a/tensorflow/python/keras/temporal_sample_weights_correctness_test.py b/tensorflow/python/keras/tests/temporal_sample_weights_correctness_test.py similarity index 100% rename from tensorflow/python/keras/temporal_sample_weights_correctness_test.py rename to tensorflow/python/keras/tests/temporal_sample_weights_correctness_test.py diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD index 226cffa6062..5693dc19b27 100644 --- a/tensorflow/tools/pip_package/BUILD +++ b/tensorflow/tools/pip_package/BUILD @@ -82,11 +82,12 @@ COMMON_PIP_DEPS = [ "//tensorflow/python/distribute:combinations", "//tensorflow/python/distribute:multi_process_runner", "//tensorflow/python/eager:eager_pip", - "//tensorflow/python/keras:model_subclassing_test_util", "//tensorflow/python/keras/layers/preprocessing:preprocessing_test_utils", "//tensorflow/python/keras/distribute:distribute_strategy_test_lib", "//tensorflow/python/keras/distribute:multi_worker_testing_utils", "//tensorflow/python/keras/mixed_precision/experimental:test_util", + "//tensorflow/python/keras/tests:model_subclassing_test_util", + "//tensorflow/python/keras/tests:model_architectures", "//tensorflow/python/kernel_tests:cudnn_deterministic_base", "//tensorflow/python/kernel_tests:bias_op_base", "//tensorflow/python/kernel_tests/random:util",