diff options
author | 2018-09-14 11:28:28 -0700 | |
---|---|---|
committer | 2018-09-14 11:32:52 -0700 | |
commit | c20a7b81d79d30db9e990309ddb419bcb48120cc (patch) | |
tree | 9ea682cf79bac18653e7690785e0f5e7117b6b8b /tensorflow/core/distributed_runtime | |
parent | 89f9080ed0d1a43cb2fa253997b2553c6916f364 (diff) |
[tf.data] Introducing an optimization that parallelizes map transformations.
Stateless MapDatasets can be paralellized by switching to ParallelMapDataset. We set `num_parallel_calls` to 2 for now, but in the future a special value will be used that result in the optimal value to be selected dynamically at runtime.
This patch also exposed a memory leak which was fixed.
PiperOrigin-RevId: 213015223
Diffstat (limited to 'tensorflow/core/distributed_runtime')
-rw-r--r-- | tensorflow/core/distributed_runtime/graph_mgr.cc | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tensorflow/core/distributed_runtime/graph_mgr.cc b/tensorflow/core/distributed_runtime/graph_mgr.cc index 6c146036ae..f7a2967d00 100644 --- a/tensorflow/core/distributed_runtime/graph_mgr.cc +++ b/tensorflow/core/distributed_runtime/graph_mgr.cc @@ -233,14 +233,11 @@ Status GraphMgr::InitItem(const string& session, const GraphDef& gdef, params.function_library = lib; params.create_kernel = [session, lib, opseg](const NodeDef& ndef, OpKernel** kernel) { - // We do not share the kernel via the OpSegment if the node is - // stateless, or a function. // NOTE(mrry): We must not share function kernels (implemented // using `CallOp`) between subgraphs, because `CallOp::handle_` // is tied to a particular subgraph. Even if the function itself // is stateful, the `CallOp` that invokes it is not. - if (!lib->IsStateful(ndef.op()) || - lib->GetFunctionLibraryDefinition()->Find(ndef.op()) != nullptr) { + if (!OpSegment::ShouldOwnKernel(lib, ndef.op())) { return lib->CreateKernel(ndef, kernel); } auto create_fn = [lib, &ndef](OpKernel** kernel) { @@ -252,8 +249,7 @@ Status GraphMgr::InitItem(const string& session, const GraphDef& gdef, return opseg->FindOrCreate(session, ndef.name(), kernel, create_fn); }; params.delete_kernel = [lib](OpKernel* kernel) { - // If the node is stateful, opseg owns it. Otherwise, delete it. - if (kernel && !lib->IsStateful(kernel->type_string())) { + if (kernel && !OpSegment::ShouldOwnKernel(lib, kernel->type_string())) { delete kernel; } }; |