aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/framework/function.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-02-01 09:55:53 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-02-01 17:06:06 -0800
commitdf344949494003ffa6eb8d9cb777558128436dc6 (patch)
treefaa8e8a6c1a76d183c5b521bb45e26837e4841c7 /tensorflow/core/framework/function.cc
parentfce33290a7b75003398761ea60b0bb6f1fdd3880 (diff)
Add shape inference for outside_compilation graph rewrite. Pull out enough of the graph to enable inference of the shape of a SendFromHost Op once the shape of corresponding RecvAtHost Ops are known.
PiperOrigin-RevId: 184153187
Diffstat (limited to 'tensorflow/core/framework/function.cc')
-rw-r--r--tensorflow/core/framework/function.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/tensorflow/core/framework/function.cc b/tensorflow/core/framework/function.cc
index d6b576166c..eae8e6c3c1 100644
--- a/tensorflow/core/framework/function.cc
+++ b/tensorflow/core/framework/function.cc
@@ -1064,26 +1064,36 @@ Status FunctionLibraryDefinition::AddLibrary(
return Status::OK();
}
-void FunctionLibraryDefinition::RemoveFunction(const string& func) {
+Status FunctionLibraryDefinition::RemoveFunction(const string& func) {
const auto& i = function_defs_.find(func);
- DCHECK(i != function_defs_.end());
+ if (i == function_defs_.end()) {
+ return errors::InvalidArgument("Tried to remove non-existent function ",
+ func);
+ }
function_defs_.erase(i);
+ return Status::OK();
}
-void FunctionLibraryDefinition::RemoveGradient(const string& func) {
+Status FunctionLibraryDefinition::RemoveGradient(const string& func) {
const auto& i = func_grad_.find(func);
- DCHECK(i != func_grad_.end());
+ if (i == func_grad_.end()) {
+ return errors::InvalidArgument("Tried to remove non-existent gradient ",
+ func);
+ }
func_grad_.erase(i);
+ return Status::OK();
}
void FunctionLibraryDefinition::Remove(
const std::vector<string>& funcs,
const std::vector<string>& funcs_with_grads) {
for (const string& f : funcs) {
- RemoveFunction(f);
+ Status s = RemoveFunction(f);
+ DCHECK(s.ok());
}
for (const string& f : funcs_with_grads) {
- RemoveGradient(f);
+ Status s = RemoveGradient(f);
+ DCHECK(s.ok());
}
}