From 4d134bad0403ebb5722144d8f859a04a5f21efc2 Mon Sep 17 00:00:00 2001 From: Derek Murray Date: Tue, 22 May 2018 13:14:18 -0700 Subject: [PATCH] Move executor_test.cc to tensorflow/core/common_runtime/. PiperOrigin-RevId: 197611583 --- tensorflow/core/BUILD | 38 ++++++++++++++++++++++ .../executor_test.cc | 0 .../testlib_ops.cc} | 20 +++++++++--- tensorflow/core/distributed_runtime/BUILD | 19 ++++++----- tensorflow/core/distributed_runtime/master_test.cc | 2 +- tensorflow/core/distributed_runtime/rpc/BUILD | 16 ++------- 6 files changed, 67 insertions(+), 28 deletions(-) rename tensorflow/core/{distributed_runtime => common_runtime}/executor_test.cc (100%) rename tensorflow/core/{distributed_runtime/rpc/grpc_testlib_ops.cc => common_runtime/testlib_ops.cc} (84%) diff --git a/tensorflow/core/BUILD b/tensorflow/core/BUILD index 5d63cd6..05b8423 100644 --- a/tensorflow/core/BUILD +++ b/tensorflow/core/BUILD @@ -1108,6 +1108,7 @@ cc_library( ":shape_inference_testutil", ":tensor_testutil", ":test", + ":testlib_ops", "//tensorflow/cc:scope", "//tensorflow/core/kernels:constant_op", "//tensorflow/core/kernels:ops_testutil", @@ -1115,6 +1116,18 @@ cc_library( ], ) +cc_library( + name = "testlib_ops", + testonly = 1, + srcs = ["common_runtime/testlib_ops.cc"], + linkstatic = 1, # Seems to be needed since alwayslink is broken in bazel + deps = [ + "//tensorflow/core:framework", + "//tensorflow/core:lib", + ], + alwayslink = 1, +) + # This is a link-only library to provide a DirectSession # implementation of the Session interface. tf_cuda_library( @@ -3749,6 +3762,31 @@ tf_cc_test( ) tf_cc_test( + name = "common_runtime_executor_test", + size = "small", + srcs = ["common_runtime/executor_test.cc"], + linkstatic = tf_kernel_tests_linkstatic(), + deps = [ + ":core", + ":core_cpu", + ":core_cpu_internal", + ":framework", + ":framework_internal", + ":lib", + ":lib_internal", + ":protos_all_cc", + ":test", + ":test_main", + ":testlib", + "//tensorflow/core/kernels:array", + "//tensorflow/core/kernels:control_flow_ops", + "//tensorflow/core/kernels:math", + "//tensorflow/core/kernels:random_ops", + "//tensorflow/core/kernels:state", + ], +) + +tf_cc_test( name = "common_runtime_function_test", size = "small", srcs = ["common_runtime/function_test.cc"], diff --git a/tensorflow/core/distributed_runtime/executor_test.cc b/tensorflow/core/common_runtime/executor_test.cc similarity index 100% rename from tensorflow/core/distributed_runtime/executor_test.cc rename to tensorflow/core/common_runtime/executor_test.cc diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_testlib_ops.cc b/tensorflow/core/common_runtime/testlib_ops.cc similarity index 84% rename from tensorflow/core/distributed_runtime/rpc/grpc_testlib_ops.cc rename to tensorflow/core/common_runtime/testlib_ops.cc index 5597ee7..a0139c3 100644 --- a/tensorflow/core/distributed_runtime/rpc/grpc_testlib_ops.cc +++ b/tensorflow/core/common_runtime/testlib_ops.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include "tensorflow/core/framework/common_shape_fns.h" #include "tensorflow/core/framework/op.h" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/platform/macros.h" @@ -21,8 +22,12 @@ namespace tensorflow { namespace test { // ErrorOp::Compute returns an error. -REGISTER_OP("Error").Input("in: T").Output("out: T").Attr("T: type").Attr( - "message: string"); +REGISTER_OP("Error") + .Input("in: T") + .Output("out: T") + .Attr("T: type") + .Attr("message: string") + .SetShapeFn(shape_inference::UnknownShape); class ErrorOp : public OpKernel { public: explicit ErrorOp(OpKernelConstruction* ctx) : OpKernel(ctx) { @@ -41,7 +46,8 @@ REGISTER_KERNEL_BUILDER(Name("Error").Device(DEVICE_CPU), ErrorOp); REGISTER_OP("InvalidRefType") .Output("out: Ref(TIn)") .Attr("TIn: type") - .Attr("TOut: type"); + .Attr("TOut: type") + .SetShapeFn(shape_inference::UnknownShape); class InvalidRefType : public OpKernel { public: explicit InvalidRefType(OpKernelConstruction* ctx) : OpKernel(ctx) { @@ -63,8 +69,12 @@ REGISTER_KERNEL_BUILDER(Name("InvalidRefType").Device(DEVICE_CPU), // DelayOp::AsyncCompute sleeps for "micros"-econd and then returns // its input. -REGISTER_OP("Delay").Input("in: T").Output("out: T").Attr("T: type").Attr( - "micros: int"); +REGISTER_OP("Delay") + .Input("in: T") + .Output("out: T") + .Attr("T: type") + .Attr("micros: int") + .SetShapeFn(shape_inference::UnchangedShape); class DelayOp : public AsyncOpKernel { public: explicit DelayOp(OpKernelConstruction* ctx) : AsyncOpKernel(ctx) { diff --git a/tensorflow/core/distributed_runtime/BUILD b/tensorflow/core/distributed_runtime/BUILD index 18b7069..ead698d 100644 --- a/tensorflow/core/distributed_runtime/BUILD +++ b/tensorflow/core/distributed_runtime/BUILD @@ -561,17 +561,19 @@ tf_cc_test( ], ) -# TODO(mrry): Move executor_test.cc to ../common_runtime when once it no longer depends -# on grpc_testlib. -tf_cuda_cc_tests( - name = "executor_tests", +tf_cuda_cc_test( + name = "master_test", size = "medium", srcs = [ - "executor_test.cc", - #"master_test.cc", # TODO(b/27683709): Re-enable when not flaky. + "master_test.cc", ], linkstatic = tf_kernel_tests_linkstatic(), - tags = tf_cuda_tests_tags(), + tags = tf_cuda_tests_tags() + [ + "manual", # TODO(b/27683709): Re-enable when not flaky. + "notap", # TODO(b/27683709): Re-enable when not flaky. + "noguitar", # TODO(b/27683709): Re-enable when not flaky. + "nooss", # TODO(b/27683709): Re-enable when not flaky. + ], deps = [ ":master", ":remote_device", @@ -588,6 +590,7 @@ tf_cuda_cc_tests( "//tensorflow/core:test_main", "//tensorflow/core:testlib", "//tensorflow/core/distributed_runtime/rpc:grpc_channel", + "//tensorflow/core/distributed_runtime/rpc:grpc_master_service_impl", "//tensorflow/core/distributed_runtime/rpc:grpc_testlib", "//tensorflow/core/distributed_runtime/rpc:grpc_util", "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", @@ -648,10 +651,10 @@ tf_cuda_cc_test( "//tensorflow/core:tensorflow", "//tensorflow/core:test", "//tensorflow/core:test_main", + "//tensorflow/core:testlib", "//tensorflow/core/distributed_runtime:server_lib", "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", "//tensorflow/core/distributed_runtime/rpc:grpc_session", - "//tensorflow/core/distributed_runtime/rpc:grpc_testlib_ops", "//tensorflow/core/kernels:aggregate_ops", "//tensorflow/core/kernels:array", ], diff --git a/tensorflow/core/distributed_runtime/master_test.cc b/tensorflow/core/distributed_runtime/master_test.cc index f2c1f34..0826a90 100644 --- a/tensorflow/core/distributed_runtime/master_test.cc +++ b/tensorflow/core/distributed_runtime/master_test.cc @@ -21,6 +21,7 @@ limitations under the License. #include "grpc++/grpc++.h" #include "tensorflow/core/distributed_runtime/rpc/grpc_channel.h" +#include "tensorflow/core/distributed_runtime/rpc/grpc_master_service_impl.h" #include "tensorflow/core/distributed_runtime/rpc/grpc_testlib.h" #include "tensorflow/core/distributed_runtime/rpc/grpc_util.h" #include "tensorflow/core/framework/allocator.h" @@ -37,7 +38,6 @@ limitations under the License. #include "tensorflow/core/platform/test.h" #include "tensorflow/core/platform/types.h" #include "tensorflow/core/protobuf/master.pb.h" -#include "tensorflow/core/protobuf/master_service.grpc.pb.h" namespace tensorflow { diff --git a/tensorflow/core/distributed_runtime/rpc/BUILD b/tensorflow/core/distributed_runtime/rpc/BUILD index 40028ee..4b2747f 100644 --- a/tensorflow/core/distributed_runtime/rpc/BUILD +++ b/tensorflow/core/distributed_runtime/rpc/BUILD @@ -314,18 +314,6 @@ tf_cc_binary( ], ) -tf_cuda_library( - name = "grpc_testlib_ops", - testonly = 1, - srcs = ["grpc_testlib_ops.cc"], - linkstatic = 1, # Seems to be needed since alwayslink is broken in bazel - deps = [ - "//tensorflow/core:framework", - "//tensorflow/core:lib", - ], - alwayslink = 1, -) - tf_cc_binary( name = "grpc_testlib_server", testonly = 1, @@ -334,11 +322,11 @@ tf_cc_binary( ], deps = [ ":grpc_server_lib", - ":grpc_testlib_ops", "//tensorflow/core:core_cpu", "//tensorflow/core:framework_internal", "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", + "//tensorflow/core:testlib", "//tensorflow/core/distributed_runtime:server_lib", "//tensorflow/core/kernels:constant_op", "//tensorflow/core/kernels:cwise_op", @@ -362,12 +350,12 @@ tf_cuda_library( visibility = ["//tensorflow:__subpackages__"], deps = [ ":grpc_session", - ":grpc_testlib_ops", "//tensorflow/core:core_cpu", "//tensorflow/core:framework", "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", "//tensorflow/core:test", + "//tensorflow/core:testlib", ], alwayslink = 1, ) -- 2.7.4