From c43c838f82f33fdc7b09221b7b32aa14298d5de8 Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Wed, 12 Jun 2019 17:19:56 -0700 Subject: [PATCH 1/6] Adding support for Eager op rewrite --- tensorflow/core/common_runtime/eager/BUILD | 18 ++++ .../eager/eager_op_rewrite_registry.cc | 47 +++++++++ .../eager/eager_op_rewrite_registry.h | 95 +++++++++++++++++++ .../eager/eager_op_rewrite_registry_test.cc | 54 +++++++++++ .../core/common_runtime/eager/execute.cc | 17 ++-- 5 files changed, 225 insertions(+), 6 deletions(-) create mode 100644 tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc create mode 100644 tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h create mode 100644 tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc diff --git a/tensorflow/core/common_runtime/eager/BUILD b/tensorflow/core/common_runtime/eager/BUILD index 138ca7e3d59..8ad8ef36b34 100644 --- a/tensorflow/core/common_runtime/eager/BUILD +++ b/tensorflow/core/common_runtime/eager/BUILD @@ -241,6 +241,7 @@ cc_library( ":context", ":copy_to_device_node", ":eager_executor", + ":eager_op_rewrite_registry", ":eager_operation", ":kernel_and_device", ":tensor_handle", @@ -262,6 +263,23 @@ cc_library( }), ) +cc_library( + name = "eager_op_rewrite_registry", + srcs = ["eager_op_rewrite_registry.cc"], + hdrs = ["eager_op_rewrite_registry.h"], + deps = [":eager_operation"], +) + +tf_cc_test( + name = "eager_op_rewrite_registry_test", + srcs = ["eager_op_rewrite_registry_test.cc"], + deps = [ + ":eager_op_rewrite_registry", + "//tensorflow/core:test", + "//tensorflow/core:test_main", + ], +) + tf_cuda_library( name = "attr_builder", srcs = ["attr_builder.cc"], diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc new file mode 100644 index 00000000000..7726c387fb6 --- /dev/null +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc @@ -0,0 +1,47 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#include "tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h" + +namespace tensorflow { + +EagerOpRewriteRegistry* EagerOpRewriteRegistry::Global() { + static EagerOpRewriteRegistry* global_rewrite_registry = + new EagerOpRewriteRegistry; + return global_rewrite_registry; +} + +void EagerOpRewriteRegistry::Register(Phase phase, + std::unique_ptr pass) { + if (rewrites_.find(phase) == rewrites_.end()) { + rewrites_[phase] = std::move(pass); + } else { + TF_CHECK_OK(errors::AlreadyExists( + "An EagerOpRewrite is already registerd for this phase: ", + pass->name())); + } +} + +Status EagerOpRewriteRegistry::RunRewrite( + Phase phase, EagerOperation* orig_op, + std::unique_ptr& out_op) { + auto rewrite = rewrites_.find(phase); + if (rewrite != rewrites_.end()) { + Status s = rewrite->second->Run(orig_op, out_op); + if (!s.ok()) return s; + } + return Status::OK(); +} + +} // namespace tensorflow diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h new file mode 100644 index 00000000000..98fc1bf34a2 --- /dev/null +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h @@ -0,0 +1,95 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ +#ifndef TENSORFLOW_CORE_COMMON_RUNTIME_EAGER_EAGER_OP_REWRITE_REGISTRY_H_ +#define TENSORFLOW_CORE_COMMON_RUNTIME_EAGER_EAGER_OP_REWRITE_REGISTRY_H_ + +#include +#include +#include "tensorflow/core/common_runtime/eager/eager_operation.h" +#include "tensorflow/core/lib/core/status.h" + +namespace tensorflow { + +// Eager op rewrites should inherit from this class and +// implement the Run method. +class EagerOpRewrite { + public: + virtual ~EagerOpRewrite() {} + + // To be implemnted by an Eager op rewrite pass. + virtual Status Run(EagerOperation* orig_op, + std::unique_ptr& out_op) = 0; + + // Sets the name of the Eager op rewrite. + void set_name(const string& name) { name_ = name; } + + // Returns the name of the Eager op rewrite. + string name() const { return name_; } + + private: + string name_; +}; + +class EagerOpRewriteRegistry { + public: + // Phases at which the Eager op rewrite pass should run. + // For now we only added PRE_EXECUTION. Expand as needed. + enum Phase { + PRE_EXECUTION // right before executing an eager op + }; + + // Add a rewrite pass to the registry. + // Only one rewrite pass is allowed per phase. + void Register(Phase phase, std::unique_ptr pass); + + // Run the rewrite pass registered for a given phase. + Status RunRewrite(Phase phase, EagerOperation* orig_op, + std::unique_ptr& out_op); + + // Returns the global registry of rewrite passes. + static EagerOpRewriteRegistry* Global(); + + private: + // Holds all the registered Eager op rewrites. + std::map> rewrites_; +}; + +namespace eager_rewrite_registration { + +// This class is used to register a new Eager Op rewrite. +class EagerRewriteRegistration { + public: + EagerRewriteRegistration(EagerOpRewriteRegistry::Phase phase, + std::unique_ptr pass, + string rewrite_pass_name) { + pass->set_name(rewrite_pass_name); + EagerOpRewriteRegistry::Global()->Register(phase, std::move(pass)); + } +}; + +} // namespace eager_rewrite_registration + +#define REGISTER_REWRITE(phase, rewrite) \ + REGISTER_REWRITE_UNIQ(__COUNTER__, phase, rewrite) + +#define REGISTER_REWRITE_UNIQ(ctr, phase, rewrite) \ + static ::tensorflow::eager_rewrite_registration::EagerRewriteRegistration \ + register_rewrite_##ctr( \ + phase, \ + ::std::unique_ptr<::tensorflow::EagerOpRewrite>(new rewrite()), \ + #rewrite) + +} // namespace tensorflow +#endif diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc new file mode 100644 index 00000000000..a5570f0b696 --- /dev/null +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc @@ -0,0 +1,54 @@ +/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +==============================================================================*/ + +#include "tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h" +#include "tensorflow/core/platform/test.h" + +namespace tensorflow { + +class TestEagerOpRewrite : public EagerOpRewrite { + public: + static int count_; + Status Run(EagerOperation* orig_op, + std::unique_ptr& out_op) override { + ++count_; + const tensorflow::AttrTypeMap* types; + bool is_function = false; + string kNewOp = "NoOp"; + TF_RETURN_IF_ERROR( + tensorflow::AttrTypeMapForOp(kNewOp.c_str(), &types, &is_function)); + // Create a new NoOp Eager operation. + out_op.reset(new tensorflow::EagerOperation(nullptr, kNewOp.c_str(), + is_function, types)); + return Status::OK(); + } +}; + +int TestEagerOpRewrite::count_ = 0; + +REGISTER_REWRITE(EagerOpRewriteRegistry::PRE_EXECUTION, TestEagerOpRewrite); + +TEST(EagerOpRewriteRegistryTest, RegisterRewritePass) { + EXPECT_EQ(0, TestEagerOpRewrite::count_); + EagerOperation* orig_op = nullptr; + std::unique_ptr out_op; + EXPECT_EQ(Status::OK(), + EagerOpRewriteRegistry::Global()->RunRewrite( + EagerOpRewriteRegistry::PRE_EXECUTION, orig_op, out_op)); + EXPECT_EQ(1, TestEagerOpRewrite::count_); + EXPECT_EQ("NoOp", out_op->Name()); +} + +} // namespace tensorflow diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index e3c179ef957..6bad6e918ab 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -51,6 +51,7 @@ limitations under the License. #include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/mutex.h" #include "tensorflow/core/util/ptr_util.h" +#include "tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h" namespace tensorflow { @@ -885,11 +886,8 @@ Status EagerRemoteExecute(EagerOperation* op, TensorHandle** retvals, // device directly. bool IsPinnableOp(const string& op_type) { static const gtl::FlatSet* unpinnable_ops = new gtl::FlatSet({ - "RandomUniform", - "RandomUniformInt", - "RandomStandardNormal", - "StatelessRandomUniform", - "StatelessRandomUniformInt", + "RandomUniform", "RandomUniformInt", "RandomStandardNormal", + "StatelessRandomUniform", "StatelessRandomUniformInt", "StatelessRandomNormal", }); @@ -999,7 +997,14 @@ Status EagerExecute(EagerOperation* op, bool op_is_local = op->EagerContext()->IsLocal(op->Device()); if (op_is_local) { - return EagerLocalExecute(op, retvals, num_retvals); + std::unique_ptr out_op; + TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite( + EagerOpRewriteRegistry::PRE_EXECUTION, op, out_op)); + if (out_op) { + return EagerLocalExecute(out_op.get(), retvals, num_retvals); + } else { + return EagerLocalExecute(op, retvals, num_retvals); + } } if (op->EagerContext()->LogDevicePlacement() || VLOG_IS_ON(1)) { From 9d0feb2b1c61a0b9938dc82436cc9a4835a2c9c7 Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Mon, 24 Jun 2019 18:12:34 -0700 Subject: [PATCH 2/6] Addressed review comments --- .../eager/eager_op_rewrite_registry.cc | 2 +- .../eager/eager_op_rewrite_registry.h | 4 ++-- .../eager/eager_op_rewrite_registry_test.cc | 8 ++++---- tensorflow/core/common_runtime/eager/execute.cc | 14 +++++++++----- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc index 7726c387fb6..88ea776b2e1 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc @@ -35,7 +35,7 @@ void EagerOpRewriteRegistry::Register(Phase phase, Status EagerOpRewriteRegistry::RunRewrite( Phase phase, EagerOperation* orig_op, - std::unique_ptr& out_op) { + std::unique_ptr* out_op) { auto rewrite = rewrites_.find(phase); if (rewrite != rewrites_.end()) { Status s = rewrite->second->Run(orig_op, out_op); diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h index 98fc1bf34a2..c56489476f0 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h @@ -30,7 +30,7 @@ class EagerOpRewrite { // To be implemnted by an Eager op rewrite pass. virtual Status Run(EagerOperation* orig_op, - std::unique_ptr& out_op) = 0; + std::unique_ptr* out_op) = 0; // Sets the name of the Eager op rewrite. void set_name(const string& name) { name_ = name; } @@ -56,7 +56,7 @@ class EagerOpRewriteRegistry { // Run the rewrite pass registered for a given phase. Status RunRewrite(Phase phase, EagerOperation* orig_op, - std::unique_ptr& out_op); + std::unique_ptr* out_op); // Returns the global registry of rewrite passes. static EagerOpRewriteRegistry* Global(); diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc index a5570f0b696..a8af053bc13 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc @@ -22,7 +22,7 @@ class TestEagerOpRewrite : public EagerOpRewrite { public: static int count_; Status Run(EagerOperation* orig_op, - std::unique_ptr& out_op) override { + std::unique_ptr* out_op) override { ++count_; const tensorflow::AttrTypeMap* types; bool is_function = false; @@ -30,8 +30,8 @@ class TestEagerOpRewrite : public EagerOpRewrite { TF_RETURN_IF_ERROR( tensorflow::AttrTypeMapForOp(kNewOp.c_str(), &types, &is_function)); // Create a new NoOp Eager operation. - out_op.reset(new tensorflow::EagerOperation(nullptr, kNewOp.c_str(), - is_function, types)); + out_op->reset(new tensorflow::EagerOperation(nullptr, kNewOp.c_str(), + is_function, types)); return Status::OK(); } }; @@ -46,7 +46,7 @@ TEST(EagerOpRewriteRegistryTest, RegisterRewritePass) { std::unique_ptr out_op; EXPECT_EQ(Status::OK(), EagerOpRewriteRegistry::Global()->RunRewrite( - EagerOpRewriteRegistry::PRE_EXECUTION, orig_op, out_op)); + EagerOpRewriteRegistry::PRE_EXECUTION, orig_op, &out_op)); EXPECT_EQ(1, TestEagerOpRewrite::count_); EXPECT_EQ("NoOp", out_op->Name()); } diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 6bad6e918ab..9e55ad69f65 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -996,10 +996,11 @@ Status EagerExecute(EagerOperation* op, bool op_is_local = op->EagerContext()->IsLocal(op->Device()); + std::unique_ptr out_op; + TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite( + EagerOpRewriteRegistry::PRE_EXECUTION, op, &out_op)); + if (op_is_local) { - std::unique_ptr out_op; - TF_RETURN_IF_ERROR(EagerOpRewriteRegistry::Global()->RunRewrite( - EagerOpRewriteRegistry::PRE_EXECUTION, op, out_op)); if (out_op) { return EagerLocalExecute(out_op.get(), retvals, num_retvals); } else { @@ -1014,8 +1015,11 @@ Status EagerExecute(EagerOperation* op, LOG(INFO) << msg; } } - - return EagerRemoteExecute(op, retvals->data(), num_retvals); + if (out_op) { + return EagerRemoteExecute(out_op.get(), retvals->data(), num_retvals); + } else { + return EagerRemoteExecute(op, retvals->data(), num_retvals); + } } Status EagerKernelExecute(EagerContext* ctx, From 109074773938e5eb072483e391ae09467734a0ef Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Tue, 25 Jun 2019 11:51:15 -0700 Subject: [PATCH 3/6] Addressed one more review comment --- .../core/common_runtime/eager/eager_op_rewrite_registry_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc index a8af053bc13..417026ada6f 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc @@ -26,7 +26,7 @@ class TestEagerOpRewrite : public EagerOpRewrite { ++count_; const tensorflow::AttrTypeMap* types; bool is_function = false; - string kNewOp = "NoOp"; + const string kNewOp = "NoOp"; TF_RETURN_IF_ERROR( tensorflow::AttrTypeMapForOp(kNewOp.c_str(), &types, &is_function)); // Create a new NoOp Eager operation. From 75c003aeacb2424b6a9abee5faf94dfd4cc35199 Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Tue, 25 Jun 2019 20:35:04 -0700 Subject: [PATCH 4/6] Addressed more review comments --- .../eager/eager_op_rewrite_registry.cc | 8 ++-- .../eager/eager_op_rewrite_registry.h | 38 +++++++++++-------- .../eager/eager_op_rewrite_registry_test.cc | 2 + 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc index 88ea776b2e1..e910136a4f4 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.cc @@ -27,9 +27,11 @@ void EagerOpRewriteRegistry::Register(Phase phase, if (rewrites_.find(phase) == rewrites_.end()) { rewrites_[phase] = std::move(pass); } else { - TF_CHECK_OK(errors::AlreadyExists( - "An EagerOpRewrite is already registerd for this phase: ", - pass->name())); + TF_CHECK_OK(errors::AlreadyExists(pass->GetDebugInfo().name, + " is already registered as" + " EagerOpRewrite for this phase in ", + pass->GetDebugInfo().file, ":", + pass->GetDebugInfo().line)); } } diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h index c56489476f0..c32ca56d50e 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry.h @@ -26,20 +26,28 @@ namespace tensorflow { // implement the Run method. class EagerOpRewrite { public: + EagerOpRewrite(string name, string file, string line) { + debug_info_.name = name; + debug_info_.file = file; + debug_info_.line = line; + } + virtual ~EagerOpRewrite() {} // To be implemnted by an Eager op rewrite pass. virtual Status Run(EagerOperation* orig_op, std::unique_ptr* out_op) = 0; - // Sets the name of the Eager op rewrite. - void set_name(const string& name) { name_ = name; } + // Holds information about the rewrite registration. + struct DebugInfo { + string name, file, line; + }; - // Returns the name of the Eager op rewrite. - string name() const { return name_; } + // Returns information about the registered Eager op rewrite. + DebugInfo GetDebugInfo() const { return debug_info_; } private: - string name_; + DebugInfo debug_info_; }; class EagerOpRewriteRegistry { @@ -72,9 +80,7 @@ namespace eager_rewrite_registration { class EagerRewriteRegistration { public: EagerRewriteRegistration(EagerOpRewriteRegistry::Phase phase, - std::unique_ptr pass, - string rewrite_pass_name) { - pass->set_name(rewrite_pass_name); + std::unique_ptr pass) { EagerOpRewriteRegistry::Global()->Register(phase, std::move(pass)); } }; @@ -82,14 +88,16 @@ class EagerRewriteRegistration { } // namespace eager_rewrite_registration #define REGISTER_REWRITE(phase, rewrite) \ - REGISTER_REWRITE_UNIQ(__COUNTER__, phase, rewrite) + REGISTER_REWRITE_UNIQ_HELPER(__COUNTER__, __FILE__, __LINE__, phase, rewrite) -#define REGISTER_REWRITE_UNIQ(ctr, phase, rewrite) \ - static ::tensorflow::eager_rewrite_registration::EagerRewriteRegistration \ - register_rewrite_##ctr( \ - phase, \ - ::std::unique_ptr<::tensorflow::EagerOpRewrite>(new rewrite()), \ - #rewrite) +#define REGISTER_REWRITE_UNIQ_HELPER(ctr, file, line, phase, rewrite) \ + REGISTER_REWRITE_UNIQ(ctr, file, line, phase, rewrite) + +#define REGISTER_REWRITE_UNIQ(ctr, file, line, phase, rewrite) \ + static ::tensorflow::eager_rewrite_registration::EagerRewriteRegistration \ + register_rewrite_##ctr(phase, \ + ::std::unique_ptr<::tensorflow::EagerOpRewrite>( \ + new rewrite(#rewrite, file, #line))) } // namespace tensorflow #endif diff --git a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc index 417026ada6f..7dd21977d86 100644 --- a/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc +++ b/tensorflow/core/common_runtime/eager/eager_op_rewrite_registry_test.cc @@ -20,6 +20,8 @@ namespace tensorflow { class TestEagerOpRewrite : public EagerOpRewrite { public: + TestEagerOpRewrite(string name, string file, string line) + : EagerOpRewrite(name, file, line) {} static int count_; Status Run(EagerOperation* orig_op, std::unique_ptr* out_op) override { From 5c9e903d594fe4e9d2a01c9ea5c9e8b0a2cdb686 Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Thu, 27 Jun 2019 11:15:03 -0700 Subject: [PATCH 5/6] Fixing small merge conflict --- tensorflow/core/common_runtime/eager/execute.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tensorflow/core/common_runtime/eager/execute.cc b/tensorflow/core/common_runtime/eager/execute.cc index 9e55ad69f65..5acd29a2e92 100644 --- a/tensorflow/core/common_runtime/eager/execute.cc +++ b/tensorflow/core/common_runtime/eager/execute.cc @@ -1015,11 +1015,17 @@ Status EagerExecute(EagerOperation* op, LOG(INFO) << msg; } } + +#if defined(IS_MOBILE_PLATFORM) + return errors::Unimplemented( + "Eager's remote execution is not available on mobile devices."); +#else // !IS_MOBILE_PLATFORM if (out_op) { return EagerRemoteExecute(out_op.get(), retvals->data(), num_retvals); } else { return EagerRemoteExecute(op, retvals->data(), num_retvals); } +#endif // !IS_MOBILE_PLATFORM } Status EagerKernelExecute(EagerContext* ctx, From ff93129764edff1688fdefd30f6a673a8a91d4c1 Mon Sep 17 00:00:00 2001 From: Mahmoud Abuzaina Date: Tue, 2 Jul 2019 11:21:57 -0700 Subject: [PATCH 6/6] Added a required dependency to BUILD file --- tensorflow/core/common_runtime/eager/BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorflow/core/common_runtime/eager/BUILD b/tensorflow/core/common_runtime/eager/BUILD index 09a717b2ac6..59d5aa5ac5b 100644 --- a/tensorflow/core/common_runtime/eager/BUILD +++ b/tensorflow/core/common_runtime/eager/BUILD @@ -276,6 +276,7 @@ tf_cc_test( srcs = ["eager_op_rewrite_registry_test.cc"], deps = [ ":eager_op_rewrite_registry", + "//tensorflow/core:lib", "//tensorflow/core:test", "//tensorflow/core:test_main", ],