Return an error instead of assertion when processing an ill-formed graph or an
authorBenoit Steiner <bsteiner@google.com>
Thu, 1 Feb 2018 22:11:08 +0000 (14:11 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 2 Feb 2018 01:31:32 +0000 (17:31 -0800)
invalid set of fetch nodes

PiperOrigin-RevId: 184192790

tensorflow/core/grappler/costs/virtual_scheduler.cc

index d7d07ee..020492a 100644 (file)
@@ -323,8 +323,13 @@ Status VirtualScheduler::Init() {
   }
 
   // Get the nodes that would run to output fetch_nodes.
+  bool ill_formed = false;
   std::vector<const NodeDef*> nodes =
-      ComputeTransitiveFanin(graph, fetch_nodes);
+      ComputeTransitiveFanin(graph, fetch_nodes, &ill_formed);
+  if (ill_formed) {
+    return errors::InvalidArgument(
+        "Ill formed graph or invalid set of fetch nodes specified");
+  }
 
   // TODO(dyoon): this is a bit inefficient as name_to_node is already built in
   // ComputeTransitiveFanin().