From 557611cefba99a7c94dc7dd0932723c0a9f96087 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Mon, 26 Feb 2018 21:09:30 -0800 Subject: [PATCH] Automated g4 rollback of changelist 187092622 PiperOrigin-RevId: 187125995 --- tensorflow/c/eager/BUILD | 1 - tensorflow/c/eager/c_api.cc | 4 ++-- tensorflow/c/eager/c_api_internal.h | 14 +------------- tensorflow/c/eager/runtime.cc | 14 ++++---------- tensorflow/c/eager/runtime.h | 3 --- tensorflow/c/eager/runtime_test.cc | 12 ++++++------ 6 files changed, 13 insertions(+), 35 deletions(-) diff --git a/tensorflow/c/eager/BUILD b/tensorflow/c/eager/BUILD index 16a2a15..e55cb67 100644 --- a/tensorflow/c/eager/BUILD +++ b/tensorflow/c/eager/BUILD @@ -21,7 +21,6 @@ tf_cuda_library( visibility = ["//visibility:public"], deps = select({ "//tensorflow:android": [ - "//tensorflow/core:lib", "//tensorflow/core:android_tensorflow_lib_lite", ], "//conditions:default": [ diff --git a/tensorflow/c/eager/c_api.cc b/tensorflow/c/eager/c_api.cc index b233dd5..bebb63c7 100644 --- a/tensorflow/c/eager/c_api.cc +++ b/tensorflow/c/eager/c_api.cc @@ -818,8 +818,8 @@ void TFE_Execute(TFE_Op* op, TFE_TensorHandle** retvals, int* num_retvals, // See WARNING comment below - would be nice to rework to avoid this // subtlety. tensorflow::tf_shared_lock l(ctx->functions_mu); - status->status = tensorflow::KernelAndDevice::Init( - ndef, ctx->func_lib(device), &ctx->runner, kernel); + status->status = + tensorflow::KernelAndDevice::Init(ndef, ctx->func_lib(device), kernel); if (!status->status.ok()) { delete kernel; return; diff --git a/tensorflow/c/eager/c_api_internal.h b/tensorflow/c/eager/c_api_internal.h index 29944df..3356054 100644 --- a/tensorflow/c/eager/c_api_internal.h +++ b/tensorflow/c/eager/c_api_internal.h @@ -31,7 +31,6 @@ limitations under the License. #include "tensorflow/core/common_runtime/function.h" #include "tensorflow/core/common_runtime/rendezvous_mgr.h" #include "tensorflow/core/framework/rendezvous.h" -#include "tensorflow/core/lib/core/threadpool.h" #include "tensorflow/core/lib/gtl/map_util.h" #include "tensorflow/core/lib/gtl/stl_util.h" #include "tensorflow/core/platform/mutex.h" @@ -46,15 +45,7 @@ struct TFE_ContextOptions { struct TFE_Context { explicit TFE_Context(const TFE_ContextOptions& opts, TF_Session* s) - : thread_pool(new tensorflow::thread::ThreadPool( - opts.session_options.options.env, "EagerCompute", - opts.session_options.options.config - .inter_op_parallelism_threads() != 0 - ? opts.session_options.options.config - .inter_op_parallelism_threads() - : tensorflow::port::NumSchedulableCPUs())), - runner([this](std::function f) { thread_pool->Schedule(f); }), - policy(opts.policy), + : policy(opts.policy), session(s), rendezvous(new tensorflow::IntraProcessRendezvous(s->device_mgr)), pflr(new tensorflow::ProcessFunctionLibraryRuntime( @@ -63,9 +54,6 @@ struct TFE_Context { log_device_placement( opts.session_options.options.config.log_device_placement()) {} - const std::unique_ptr thread_pool; - std::function)> runner; - const TFE_ContextDevicePlacementPolicy policy; // Note: we cannot use C++11 thread_local here as there is no concept of a diff --git a/tensorflow/c/eager/runtime.cc b/tensorflow/c/eager/runtime.cc index b961842..4bf24fe 100644 --- a/tensorflow/c/eager/runtime.cc +++ b/tensorflow/c/eager/runtime.cc @@ -255,22 +255,17 @@ Status KernelAndDevice::InitOp(Device* device, const NodeDef& ndef, out->device_ = device; out->kernel_.reset(k); out->flib_ = nullptr; - out->runner_ = nullptr; - out->default_runner_ = [](std::function f) { f(); }; return s; } // static Status KernelAndDevice::Init(const NodeDef& ndef, FunctionLibraryRuntime* flib, - std::function)>* runner, KernelAndDevice* out) { OpKernel* k = nullptr; Status s = flib->CreateKernel(ndef, &k); out->device_ = flib->device(); out->kernel_.reset(k); out->flib_ = flib; - out->runner_ = runner; - out->default_runner_ = [](std::function f) { f(); }; return s; } @@ -301,11 +296,10 @@ Status KernelAndDevice::Run(std::vector* input_tensors, if (stats != nullptr) { params.track_allocations = true; } - if (runner_ == nullptr) { - params.runner = &default_runner_; - } else { - params.runner = runner_; - } + // TODO(apassos): use a thread pool. + std::function)> runner = + [](std::function f) { f(); }; + params.runner = &runner; OpKernelContext context(¶ms); device_->Compute(kernel_.get(), &context); diff --git a/tensorflow/c/eager/runtime.h b/tensorflow/c/eager/runtime.h index fa5f839..7fede4d 100644 --- a/tensorflow/c/eager/runtime.h +++ b/tensorflow/c/eager/runtime.h @@ -169,7 +169,6 @@ class KernelAndDevice { // the FunctionLibraryRuntime is pushed on to the caller (see locking in // c_api.cc). static Status Init(const NodeDef& ndef, FunctionLibraryRuntime* flib, - std::function)>* runner, KernelAndDevice* out); // TODO(ashankar): Remove this static Status InitOp(Device* device, const NodeDef& ndef, @@ -189,8 +188,6 @@ class KernelAndDevice { private: std::unique_ptr kernel_; Device* device_; - std::function)>* runner_; - std::function)> default_runner_; FunctionLibraryRuntime* flib_; checkpoint::TensorSliceReaderCacheWrapper slice_reader_cache_; Rendezvous* rendez_; diff --git a/tensorflow/c/eager/runtime_test.cc b/tensorflow/c/eager/runtime_test.cc index ab0b535..6431530 100644 --- a/tensorflow/c/eager/runtime_test.cc +++ b/tensorflow/c/eager/runtime_test.cc @@ -92,8 +92,8 @@ TEST(KernelAndDevice, Run) { .BuildNodeDef()); TestEnv env; KernelAndDevice kernel(nullptr); - Status s = KernelAndDevice::Init(ndef, env.function_library_runtime(), - nullptr, &kernel); + Status s = + KernelAndDevice::Init(ndef, env.function_library_runtime(), &kernel); ASSERT_TRUE(s.ok()) << s; std::vector outputs; s = kernel.Run(&inputs, &outputs, nullptr); @@ -158,8 +158,8 @@ void BM_KernelAndDeviceInit(int iters) { KernelAndDevice k(nullptr); tensorflow::testing::StartTiming(); for (int i = 0; i < iters; ++i) { - TF_CHECK_OK(KernelAndDevice::Init(ndef, env.function_library_runtime(), - nullptr, &k)); + TF_CHECK_OK( + KernelAndDevice::Init(ndef, env.function_library_runtime(), &k)); } } BENCHMARK(BM_KernelAndDeviceInit); @@ -179,8 +179,8 @@ void BM_KernelAndDeviceRun(int iters) { .BuildNodeDef()); TestEnv env; KernelAndDevice kernel(nullptr); - TF_CHECK_OK(KernelAndDevice::Init(ndef, env.function_library_runtime(), - nullptr, &kernel)); + TF_CHECK_OK( + KernelAndDevice::Init(ndef, env.function_library_runtime(), &kernel)); tensorflow::testing::StartTiming(); for (int i = 0; i < iters; ++i) { TF_CHECK_OK(kernel.Run(&inputs, &outputs, nullptr)); -- 2.7.4