Add the exception handle for grappler pass.
@@ -35,6 +35,7 @@ class GrapplerOptimizer(GraphRewriterBase):
@dump_elapsed_time("Pass GrapplerOptimizer")
def do_transformation(self):
+ try:
g = tf.Graph()
with g.as_default():
g = tf.compat.v1.import_graph_def(self.model, name='')
@@ -55,3 +56,6 @@ class GrapplerOptimizer(GraphRewriterBase):
optimized_graph = tf_optimizer.OptimizeGraph(config, meta_graph)
return optimized_graph
+ except Exception as e:
+ self.logger.warning("Failed to run grappler pass due to {}".format(str(e)))
+ return self.model
