From 32b7183acd12766103fcacdd55d826a823c85d58 Mon Sep 17 00:00:00 2001 From: Deven Desai Date: Tue, 31 Dec 2019 17:01:07 +0000 Subject: [PATCH] [ROCm] Unit-test updates for the ROCm platform. This commit mostly either enables or disables unittests on the ROCM platform, details listed below * adding/removing no_rocm tag for tests in the //tensorflow/compiler/mlir dir * enabling / disabling subtests within //tensorflow/core/grappler/optimizers:constant_folding_test for the ROCm platform * disabling a subtest within //tensorflow/core/distributed_runtime:collective_param_resolver_distributed_test fir the ROCm platform * adding no_rocm tag to tests that are failing on the ROCm platform * minor bug fix to ensure that the //tensorflow/compiler/mlir/tensorflow:error_util_test passes on a consistent basis --- tensorflow/compiler/mlir/glob_lit_test.bzl | 2 +- tensorflow/compiler/mlir/lite/tests/BUILD | 5 ++++ .../compiler/mlir/lite/tests/end2end/BUILD | 6 ++++ tensorflow/compiler/mlir/tensorflow/BUILD | 1 - .../compiler/mlir/tensorflow/tests/BUILD | 4 +++ ...lective_param_resolver_distributed_test.cc | 2 +- .../optimizers/constant_folding_test.cc | 28 +++++++++++-------- tensorflow/lite/python/BUILD | 2 ++ tensorflow/python/BUILD | 7 ++++- tensorflow/python/debug/BUILD | 2 ++ tensorflow/python/distribute/BUILD | 1 + tensorflow/python/feature_column/BUILD | 2 ++ tensorflow/python/keras/applications/BUILD | 1 + tensorflow/python/keras/layers/BUILD | 6 +++- .../python/keras/legacy_tf_layers/BUILD | 1 + tensorflow/python/keras/saving/BUILD | 1 + tensorflow/python/ops/ragged/BUILD | 1 + tensorflow/python/tpu/BUILD | 1 + tensorflow/tools/docs/BUILD | 1 + 19 files changed, 57 insertions(+), 17 deletions(-) diff --git a/tensorflow/compiler/mlir/glob_lit_test.bzl b/tensorflow/compiler/mlir/glob_lit_test.bzl index 422fca3308e..d69560220f2 100644 --- a/tensorflow/compiler/mlir/glob_lit_test.bzl +++ b/tensorflow/compiler/mlir/glob_lit_test.bzl @@ -12,7 +12,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") _default_test_file_exts = ["mlir", ".pbtxt", ".td"] _default_driver = "@llvm-project//mlir:run_lit.sh" _default_size = "small" -_default_tags = ["no_rocm"] +_default_tags = [] # These are patterns which we should never match, for tests, subdirectories, or # test input data files. diff --git a/tensorflow/compiler/mlir/lite/tests/BUILD b/tensorflow/compiler/mlir/lite/tests/BUILD index a4ebc997991..0d612cec961 100644 --- a/tensorflow/compiler/mlir/lite/tests/BUILD +++ b/tensorflow/compiler/mlir/lite/tests/BUILD @@ -5,6 +5,11 @@ package(licenses = ["notice"]) glob_lit_tests( data = [":test_utilities"], driver = "@llvm-project//mlir:run_lit.sh", + tags_override = { + "legalize-tf.mlir": ["no_rocm"], + "optimize.mlir": ["no_rocm"], + "prepare-tf.mlir": ["no_rocm"], + }, test_file_exts = ["mlir"], ) diff --git a/tensorflow/compiler/mlir/lite/tests/end2end/BUILD b/tensorflow/compiler/mlir/lite/tests/end2end/BUILD index 732fd784bbc..9d768fec0ab 100644 --- a/tensorflow/compiler/mlir/lite/tests/end2end/BUILD +++ b/tensorflow/compiler/mlir/lite/tests/end2end/BUILD @@ -8,6 +8,12 @@ glob_lit_tests( ":test_utilities", ], driver = "@llvm-project//mlir:run_lit.sh", + tags_override = { + "add.pbtxt": ["no_rocm"], + "conv_2d.pbtxt": ["no_rocm"], + "fake_quant_per_channel.pbtxt": ["no_rocm"], + "ophint_lstm.pbtxt": ["no_rocm"], + }, test_file_exts = [ "pbtxt", ], diff --git a/tensorflow/compiler/mlir/tensorflow/BUILD b/tensorflow/compiler/mlir/tensorflow/BUILD index 90370bbed61..8cfb33fa36e 100644 --- a/tensorflow/compiler/mlir/tensorflow/BUILD +++ b/tensorflow/compiler/mlir/tensorflow/BUILD @@ -934,7 +934,6 @@ cc_library( tf_cc_test( name = "error_util_test", srcs = ["utils/error_util_test.cc"], - tags = ["no_rocm"], deps = [ ":error_util", "//tensorflow/compiler/xla:test", diff --git a/tensorflow/compiler/mlir/tensorflow/tests/BUILD b/tensorflow/compiler/mlir/tensorflow/tests/BUILD index a4ebc997991..daa583bed0e 100644 --- a/tensorflow/compiler/mlir/tensorflow/tests/BUILD +++ b/tensorflow/compiler/mlir/tensorflow/tests/BUILD @@ -5,6 +5,10 @@ package(licenses = ["notice"]) glob_lit_tests( data = [":test_utilities"], driver = "@llvm-project//mlir:run_lit.sh", + tags_override = { + "optimize.mlir": ["no_rocm"], + "tf_optimize.mlir": ["no_rocm"], + }, test_file_exts = ["mlir"], ) diff --git a/tensorflow/core/distributed_runtime/collective_param_resolver_distributed_test.cc b/tensorflow/core/distributed_runtime/collective_param_resolver_distributed_test.cc index cd6a3d53b7d..13e61e55ee0 100644 --- a/tensorflow/core/distributed_runtime/collective_param_resolver_distributed_test.cc +++ b/tensorflow/core/distributed_runtime/collective_param_resolver_distributed_test.cc @@ -315,7 +315,7 @@ TEST_F(DeviceResDistTest, Workers2Devices2) { ValidateCollectiveParams(num_workers, num_devices); } -#ifndef GOOGLE_CUDA +#if !GOOGLE_CUDA && !TENSORFLOW_USE_ROCM namespace { // A mock NcclReducer for testing group runtime details initialization with CPU // builds. The only meaningful function in this class is diff --git a/tensorflow/core/grappler/optimizers/constant_folding_test.cc b/tensorflow/core/grappler/optimizers/constant_folding_test.cc index 569f6433edb..6c829bb353b 100644 --- a/tensorflow/core/grappler/optimizers/constant_folding_test.cc +++ b/tensorflow/core/grappler/optimizers/constant_folding_test.cc @@ -551,9 +551,9 @@ TEST_F(ConstantFoldingTest, ConstantPushDownBiasAdd) { TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_ScalarConst) { for (string data_format : { "NHWC", -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM "NCHW" -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM }) { MulConvPushDownTest( /*input_shape=*/data_format == "NHWC" ? TensorShape{4, 10, 10, 3} @@ -569,9 +569,9 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_ScalarConst) { TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_SingletonConst) { for (string data_format : { "NHWC", -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM "NCHW" -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM }) { for (auto mul_const_input_shape : {TensorShape{1}, TensorShape{1, 1, 1, 1}}) { @@ -590,9 +590,9 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_SingletonConst_ShapeMismatch) { for (string data_format : { "NHWC", -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM "NCHW" -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM }) { MulConvPushDownTest( /*input_shape=*/data_format == "NHWC" ? TensorShape{4, 10, 10, 3} @@ -608,9 +608,9 @@ TEST_F(ConstantFoldingTest, TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_3x1x3Const) { for (auto data_format : { "NHWC", -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM "NCHW" -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM }) { MulConvPushDownTest( /*input_shape=*/{3, 3, 3, 3}, @@ -635,7 +635,7 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_NHWC_VectorLikeConst) { } } -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_NCHW_VectorLikeConst) { for (auto mul_const_input_shape : {TensorShape{3}, TensorShape{3, 1, 1}, TensorShape{1, 3, 1, 1}}) { @@ -649,14 +649,14 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_NCHW_VectorLikeConst) { /*expect_folded=*/false); } } -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_3x1Const) { for (auto data_format : { "NHWC", -#if GOOGLE_CUDA +#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM "NCHW" -#endif // GOOGLE_CUDA +#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM }) { MulConvPushDownTest( /*input_shape=*/{3, 3, 3, 3}, @@ -668,6 +668,9 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv2D_3x1Const) { } } +// This test fails on ROCm platform with two vaue miscompare +// TODO(rocm) : analysze and fix the cause of the failure and re-enable test +#ifndef TENSORFLOW_USE_ROCM TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv3D_NDHWC_1x1x3Const) { MulConvPushDownTest( /*input_shape=*/{3, 3, 3, 3, 3}, @@ -678,6 +681,7 @@ TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv3D_NDHWC_1x1x3Const) { /*data_format=*/"NDHWC", /*expect_folded=*/true); } +#endif TEST_F(ConstantFoldingTest, MulConvPushDownTest_Conv3D_NCDHW_3x1x1x1Const) { MulConvPushDownTest( diff --git a/tensorflow/lite/python/BUILD b/tensorflow/lite/python/BUILD index 5903a96fb52..6a8e848edfb 100644 --- a/tensorflow/lite/python/BUILD +++ b/tensorflow/lite/python/BUILD @@ -143,6 +143,7 @@ py_test( shard_count = 4, srcs_version = "PY2AND3", tags = [ + "no_rocm", "no_windows", ], deps = [ @@ -159,6 +160,7 @@ py_test( python_version = "PY3", srcs_version = "PY2AND3", tags = [ + "no_rocm", "no_windows", ], deps = [ diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index d932899ab0d..6589b8afd74 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -3197,6 +3197,7 @@ tf_py_test( size = "small", srcs = ["ops/collective_ops_test.py"], python_version = "PY3", + tags = ["no_rocm"], deps = [ ":client_testlib", ":collective_ops", @@ -6425,6 +6426,7 @@ tf_py_test( size = "small", srcs = ["framework/convert_to_constants_test.py"], python_version = "PY3", + tags = ["no_rocm"], deps = [ "client_testlib", "framework_test_lib", @@ -6449,7 +6451,10 @@ tf_py_test( size = "small", srcs = ["lib/io/file_io_test.py"], python_version = "PY3", - tags = ["no_windows"], + tags = [ + "no_rocm", + "no_windows", + ], deps = [ ":client_testlib", ":errors", diff --git a/tensorflow/python/debug/BUILD b/tensorflow/python/debug/BUILD index f9781ca6791..f0c19563af7 100644 --- a/tensorflow/python/debug/BUILD +++ b/tensorflow/python/debug/BUILD @@ -926,6 +926,7 @@ py_test( srcs = ["wrappers/framework_test.py"], python_version = "PY3", srcs_version = "PY2AND3", + tags = ["no_rocm"], deps = [ ":debug_data", ":framework", @@ -1146,6 +1147,7 @@ py_test( srcs = ["cli/debugger_cli_common_test.py"], python_version = "PY3", srcs_version = "PY2AND3", + tags = ["no_rocm"], deps = [ ":debugger_cli_common", "//tensorflow/python:framework_test_lib", diff --git a/tensorflow/python/distribute/BUILD b/tensorflow/python/distribute/BUILD index fd4895e6e02..76856ea889e 100644 --- a/tensorflow/python/distribute/BUILD +++ b/tensorflow/python/distribute/BUILD @@ -177,6 +177,7 @@ py_test( srcs = ["distribute_lib_test.py"], python_version = "PY3", srcs_version = "PY2AND3", + tags = ["no_rocm"], deps = [ ":combinations", ":distribute_lib", diff --git a/tensorflow/python/feature_column/BUILD b/tensorflow/python/feature_column/BUILD index b29214f3f07..2e2b831750a 100644 --- a/tensorflow/python/feature_column/BUILD +++ b/tensorflow/python/feature_column/BUILD @@ -113,6 +113,7 @@ tf_py_test( tags = [ "no_cuda_on_cpu_tap", "no_pip", + "no_rocm", "no_windows", ], deps = [ @@ -165,6 +166,7 @@ tf_py_test( tags = [ "no_cuda_on_cpu_tap", "no_pip", + "no_rocm", "no_windows", ], deps = [":feature_column_v2_test_main_lib"], diff --git a/tensorflow/python/keras/applications/BUILD b/tensorflow/python/keras/applications/BUILD index 39c562c66c3..4c76983d22d 100644 --- a/tensorflow/python/keras/applications/BUILD +++ b/tensorflow/python/keras/applications/BUILD @@ -43,6 +43,7 @@ tf_py_test( size = "medium", srcs = ["applications_test.py"], shard_count = 36, + tags = ["no_rocm"], deps = [ ":applications", "//tensorflow/python:client_testlib", diff --git a/tensorflow/python/keras/layers/BUILD b/tensorflow/python/keras/layers/BUILD index 247b139478c..5cb080fa5e0 100644 --- a/tensorflow/python/keras/layers/BUILD +++ b/tensorflow/python/keras/layers/BUILD @@ -650,7 +650,10 @@ tf_py_test( srcs = ["gru_test.py"], python_version = "PY3", shard_count = 4, - tags = ["notsan"], # http://b/62136390 + tags = [ + "no_rocm", + "notsan", # http://b/62136390 + ], deps = [ "//tensorflow/python:client_testlib", "//tensorflow/python/keras", @@ -666,6 +669,7 @@ tf_py_test( python_version = "PY3", shard_count = 4, tags = [ + "no_rocm", "noasan", # times out b/63678675 "notsan", # http://b/62189182 ], diff --git a/tensorflow/python/keras/legacy_tf_layers/BUILD b/tensorflow/python/keras/legacy_tf_layers/BUILD index 6789acc74cb..b4b533d0f4a 100644 --- a/tensorflow/python/keras/legacy_tf_layers/BUILD +++ b/tensorflow/python/keras/legacy_tf_layers/BUILD @@ -157,6 +157,7 @@ tf_py_test( srcs = ["pooling_test.py"], main = "pooling_test.py", python_version = "PY3", + tags = ["no_rocm"], deps = [ ":pooling", "//tensorflow/python:array_ops", diff --git a/tensorflow/python/keras/saving/BUILD b/tensorflow/python/keras/saving/BUILD index eda5776c7a6..67a984946e3 100644 --- a/tensorflow/python/keras/saving/BUILD +++ b/tensorflow/python/keras/saving/BUILD @@ -136,6 +136,7 @@ tf_py_test( python_version = "PY3", shard_count = 4, tags = [ + "no_rocm", "no_windows", ], deps = [ diff --git a/tensorflow/python/ops/ragged/BUILD b/tensorflow/python/ops/ragged/BUILD index c7157f6ac1d..4d2161a93b8 100644 --- a/tensorflow/python/ops/ragged/BUILD +++ b/tensorflow/python/ops/ragged/BUILD @@ -1093,6 +1093,7 @@ py_test( srcs = ["ragged_map_fn_op_test.py"], python_version = "PY3", srcs_version = "PY2AND3", + tags = ["no_rocm"], deps = [ ":ragged", # fixdeps: keep ":ragged_factory_ops", diff --git a/tensorflow/python/tpu/BUILD b/tensorflow/python/tpu/BUILD index cf32d933e0c..ebf0a4ffc57 100644 --- a/tensorflow/python/tpu/BUILD +++ b/tensorflow/python/tpu/BUILD @@ -32,6 +32,7 @@ py_test( "no_oss_py2", "no_oss_py35", "no_pip", + "no_rocm", ], deps = [ "//tensorflow/python:client_testlib", diff --git a/tensorflow/tools/docs/BUILD b/tensorflow/tools/docs/BUILD index 5d349da84bf..97aedfd9fa2 100644 --- a/tensorflow/tools/docs/BUILD +++ b/tensorflow/tools/docs/BUILD @@ -26,6 +26,7 @@ py_test( tags = [ "no_oss_py2", "no_pip", + "no_rocm", "no_windows", # numpy prints differently on windows. "noasan", "nomsan",