[Bugfix][TF] reset graph after getting tag of savedmodel (#4055)
authorYong Wu <ywu118@alumni.jh.edu>
Sun, 6 Oct 2019 00:33:14 +0000 (17:33 -0700)
committerYao Wang <kevinthesunwy@gmail.com>
Sun, 6 Oct 2019 00:33:14 +0000 (17:33 -0700)
@zhiics @icemelon9

python/tvm/relay/frontend/tensorflow_parser.py

index 8105ef0..d1c0bfe 100644 (file)
@@ -79,15 +79,16 @@ class TFParser(object):
                 "InputConfiguration: Unable to import tensorflow which is "
                 "required to restore from saved model.")
         tags = self._get_tag_set()
+        output_names = set()
         with tf.Session() as sess:
             meta_graph_def = tf.saved_model.loader.load(sess,
                                                         tags,
                                                         self._model_dir)
-            output_names = set()
             for sig_def in meta_graph_def.signature_def.values():
                 for output_tensor in sig_def.outputs.values():
                     output_names.add(output_tensor.name.replace(":0", ""))
-            return ",".join(output_names)
+        tf.reset_default_graph()
+        return ",".join(output_names)
 
     def _load_saved_model(self):
         """Load the tensorflow saved model."""