diff options
author | Max Galkin <maxgalkin@google.com> | 2018-01-25 16:08:13 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-01-25 16:14:29 -0800 |
commit | 9581462f8743ee92f39d46263d68fc1283082b44 (patch) | |
tree | a319d2a3319bafeeb2b86a3e5cbb3525c08cd51a | |
parent | 4f9ef6c625913947b8c83cdaef957b23b0bada62 (diff) |
Show friendlier error message on failure in tf_optimizer.i
Without it we trigger a segmentation fault, but later in a different stack, which is not so helpful.
PiperOrigin-RevId: 183307729
-rw-r--r-- | tensorflow/python/grappler/tf_optimizer.i | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tensorflow/python/grappler/tf_optimizer.i b/tensorflow/python/grappler/tf_optimizer.i index f0dd4483a6..1b657983a4 100644 --- a/tensorflow/python/grappler/tf_optimizer.i +++ b/tensorflow/python/grappler/tf_optimizer.i @@ -103,6 +103,11 @@ PyObject* TF_OptimizeGraph( std::unique_ptr<tensorflow::grappler::GrapplerItem> grappler_item = tensorflow::grappler::GrapplerItemFromMetaGraphDef(graph_id, metagraph, item_config); + if (!grappler_item) { + TF_SetStatus(out_status, TF_INVALID_ARGUMENT, "Failed to import metagraph, check error log for more info."); + return nullptr; + } + tensorflow::DeviceBase* cpu_device = nullptr; tensorflow::GraphDef out_graph; tensorflow::grappler::MetaOptimizer optimizer(cpu_device, rewriter_config); |