aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/core/framework')
-rw-r--r--tensorflow/core/framework/function.cc24
-rw-r--r--tensorflow/core/framework/function.h7
2 files changed, 27 insertions, 4 deletions
diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc
index 20f957190b..aa2f274752 100644
--- a/tensorflow/core/framework/function.cc
+++ b/tensorflow/core/framework/function.cc
@@ -796,12 +796,28 @@ uint64 FunctionDefHash(const FunctionDef& fdef) {
return h;
}
+static constexpr const char* const kExecutorAttr = "_executor";
+
+/* static */
+string FunctionLibraryRuntime::ExecutorType(const InstantiateOptions& options,
+ AttrSlice attrs) {
+ if (!options.executor_type.empty()) {
+ return options.executor_type;
+ } else if (const AttrValue* executor_attr = attrs.Find(kExecutorAttr)) {
+ return executor_attr->s();
+ } else {
+ return string();
+ }
+}
+
string Canonicalize(const string& funcname, AttrSlice attrs,
const FunctionLibraryRuntime::InstantiateOptions& options) {
std::vector<string> entries;
entries.reserve(options.target.empty() ? attrs.size() : (attrs.size() + 1));
for (auto p : attrs) {
- entries.push_back(strings::StrCat(p.first, "=", Print(p.second)));
+ if (p.first != kExecutorAttr) {
+ entries.push_back(strings::StrCat(p.first, "=", Print(p.second)));
+ }
}
if (!options.target.empty()) {
entries.push_back(
@@ -815,9 +831,9 @@ string Canonicalize(const string& funcname, AttrSlice attrs,
entries.push_back(
strings::StrCat("_state_handle", "=", options.state_handle));
}
- if (!options.executor_type.empty()) {
- entries.push_back(
- strings::StrCat("_executor_type", "=", options.executor_type));
+ string executor_type = FunctionLibraryRuntime::ExecutorType(options, attrs);
+ if (!executor_type.empty()) {
+ entries.push_back(strings::StrCat(kExecutorAttr, "=", executor_type));
}
std::sort(entries.begin(), entries.end());
return strings::StrCat(funcname, "[", str_util::Join(entries, ","), "]");
diff --git a/tensorflow/core/framework/function.h b/tensorflow/core/framework/function.h
index 4d6d68e214..d4beca7e11 100644
--- a/tensorflow/core/framework/function.h
+++ b/tensorflow/core/framework/function.h
@@ -609,6 +609,13 @@ class FunctionLibraryRuntime {
virtual Status Clone(std::unique_ptr<FunctionLibraryDefinition>* out_lib_def,
std::unique_ptr<ProcessFunctionLibraryRuntime>* out_pflr,
FunctionLibraryRuntime** out_flr) = 0;
+
+ // Returns the name of the executor class (in the sense of
+ // `ExecutorFactory::GetFactory()`) that will be used based on the given
+ // dynamic `options` and static `attrs`. If none is specified, this method
+ // will return an empty string, which leaves the decision up to the runtime.
+ static string ExecutorType(const InstantiateOptions& options,
+ AttrSlice attrs);
};
// Returns a canonicalized string for the instantiation of the