aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/function.cc
diff options
context:
space:
mode:
authorGravatar Derek Murray <mrry@google.com>2018-01-04 14:48:09 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-04 14:51:51 -0800
commit19bbc31eee8b81bce6eb08b7ada539943fac6014 (patch)
tree079f8dcc4b87783f3c356011e5708e11a33814d4 /tensorflow/core/framework/function.cc
parentb639608a6da140f720636582022a575d7c8a7650 (diff)
Add `FunctionLibraryRuntime::InstantiateOptions` struct.
This new struct allows optional arguments to be passed to the `FunctionLibraryRuntime::Instantiate()` API. The new struct is now used to configure the target device for a function instantiation (instead of an attr). PiperOrigin-RevId: 180848930
Diffstat (limited to 'tensorflow/core/framework/function.cc')
-rw-r--r--tensorflow/core/framework/function.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc
index d757e962e5..783015481a 100644
--- a/tensorflow/core/framework/function.cc
+++ b/tensorflow/core/framework/function.cc
@@ -795,12 +795,17 @@ uint64 FunctionDefHash(const FunctionDef& fdef) {
return h;
}
-string Canonicalize(const string& funcname, AttrSlice attrs) {
+string Canonicalize(const string& funcname, AttrSlice attrs,
+ const FunctionLibraryRuntime::InstantiateOptions& options) {
std::vector<string> entries;
- entries.reserve(attrs.size());
+ 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 (!options.target.empty()) {
+ entries.push_back(
+ strings::StrCat("_target", "=", str_util::CEscape(options.target)));
+ }
std::sort(entries.begin(), entries.end());
return strings::StrCat(funcname, "[", str_util::Join(entries, ","), "]");
}