From: Akshay Agrawal Date: Sat, 26 May 2018 00:12:49 +0000 (-0700) Subject: Provide a step container to OpKernelContexts when running eagerly. X-Git-Tag: upstream/v1.9.0_rc1~38^2~4^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=06717b77e05bd602d10fe40f4519dbb105fabd5c;p=platform%2Fupstream%2Ftensorflow.git Provide a step container to OpKernelContexts when running eagerly. This lets us run some ops that require step containers (e.g. TensorArray-related ops). Before change: Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------- BM_CreateGraph 61292 80915 8581 BM_RunGraph 7899 13398 51251 BM_CreateAndDestroySession 2588 2594 269838 BM_KernelAndDeviceInit 2971 2976 235908 BM_KernelAndDeviceRun 505 506 1000000 After change: Benchmark Time(ns) CPU(ns) Iterations ------------------------------------------------------------------- BM_CreateGraph 78295 105539 8698 BM_RunGraph 9907 16988 47908 BM_CreateAndDestroySession 2773 2778 247635 BM_KernelAndDeviceInit 2678 2682 270054 BM_KernelAndDeviceRun 553 554 1000000 PiperOrigin-RevId: 198125630 --- diff --git a/tensorflow/core/common_runtime/eager/kernel_and_device.cc b/tensorflow/core/common_runtime/eager/kernel_and_device.cc index a63b2b9..2a43a31 100644 --- a/tensorflow/core/common_runtime/eager/kernel_and_device.cc +++ b/tensorflow/core/common_runtime/eager/kernel_and_device.cc @@ -19,6 +19,7 @@ limitations under the License. #include "tensorflow/core/common_runtime/rendezvous_mgr.h" #include "tensorflow/core/framework/allocator.h" #include "tensorflow/core/framework/node_def.pb.h" +#include "tensorflow/core/framework/resource_mgr.h" #include "tensorflow/core/framework/step_stats.pb.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/gtl/map_util.h" @@ -86,6 +87,11 @@ Status KernelAndDevice::Run(std::vector* input_tensors, [](std::function f) { f(); }; params.runner = &runner; + ScopedStepContainer step_container(0, [this](const string& name) { + device_->resource_manager()->Cleanup(name).IgnoreError(); + }); + params.step_container = &step_container; + OpKernelContext context(¶ms); if (kernel_->def().op() == "_Recv") {