aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework
diff options
context:
space:
mode:
authorGravatar Tong Shen <endlessroad@google.com>2018-09-12 10:03:32 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-12 10:07:48 -0700
commit37ddb13ece32500bf87af5d8b8493be1c77781de (patch)
treed3b5daf4c29b5402a0db9e3f316665b5c1d1a9b1 /tensorflow/core/framework
parent26509bf4e202c09da4f0b00d43ebddf87368a0f2 (diff)
Roll forward change "Move control flow functionalization as a graph optimization pass, instead of a step in XlaCompiler.".
PiperOrigin-RevId: 212657932
Diffstat (limited to 'tensorflow/core/framework')
-rw-r--r--tensorflow/core/framework/function.cc11
-rw-r--r--tensorflow/core/framework/function.h4
2 files changed, 15 insertions, 0 deletions
diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc
index 26f32677af..d979353d2f 100644
--- a/tensorflow/core/framework/function.cc
+++ b/tensorflow/core/framework/function.cc
@@ -1154,6 +1154,17 @@ Status FunctionLibraryDefinition::LookUp(
return default_registry_->LookUp(op, op_reg_data);
}
+string FunctionLibraryDefinition::UniqueFunctionName(StringPiece prefix) const {
+ tf_shared_lock l(mu_);
+ int index = 0;
+ string name = strings::StrCat(prefix, index);
+ while (function_defs_.find(name) != function_defs_.end()) {
+ ++index;
+ name = strings::StrCat(prefix, index);
+ }
+ return name;
+}
+
const FunctionDef* FunctionLibraryDefinition::GetAttrImpl(
const NodeDef& ndef) const {
if (ndef.op() != kGradientOp) {
diff --git a/tensorflow/core/framework/function.h b/tensorflow/core/framework/function.h
index 03296a7761..e01eb7503d 100644
--- a/tensorflow/core/framework/function.h
+++ b/tensorflow/core/framework/function.h
@@ -358,6 +358,10 @@ class FunctionLibraryDefinition : public OpRegistryInterface {
const OpRegistrationData** op_reg_data) const override
LOCKS_EXCLUDED(mu_);
+ // Generates new function name with the specified prefix that is unique
+ // across this library.
+ string UniqueFunctionName(StringPiece prefix) const LOCKS_EXCLUDED(mu_);
+
// Ops created for function arguments bear the name given by `kArgOp`; those
// created for return values bear the name given by `kRetOp`.
static constexpr const char* const kArgOp = "_Arg";