From 5e84286893d8894732b253a4d3e416bd6e270e08 Mon Sep 17 00:00:00 2001 From: Jay Zhang Date: Thu, 29 Sep 2022 23:14:14 +0800 Subject: [PATCH] Remove extract_sub_graph function from tf_optimize method because it is not needed. Signed-off-by: Jay Zhang --- tf2onnx/tf_loader.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tf2onnx/tf_loader.py b/tf2onnx/tf_loader.py index d9d72a8dc..2f969f77e 100644 --- a/tf2onnx/tf_loader.py +++ b/tf2onnx/tf_loader.py @@ -74,7 +74,6 @@ def not_implemented_tf_placeholder(*args, **kwargs): tf_gfile = tf.io.gfile tf_placeholder = tf.compat.v1.placeholder tf_placeholder_with_default = tf.compat.v1.placeholder_with_default - extract_sub_graph = tf.compat.v1.graph_util.extract_sub_graph elif Version(tf.__version__) >= Version("1.13"): # 1.13 introduced the compat namespace tf_reset_default_graph = tf.compat.v1.reset_default_graph @@ -85,7 +84,6 @@ def not_implemented_tf_placeholder(*args, **kwargs): tf_gfile = tf.gfile tf_placeholder = tf.compat.v1.placeholder tf_placeholder_with_default = tf.compat.v1.placeholder_with_default - extract_sub_graph = tf.compat.v1.graph_util.extract_sub_graph else: # older than 1.13 tf_reset_default_graph = tf.reset_default_graph @@ -96,7 +94,6 @@ def not_implemented_tf_placeholder(*args, **kwargs): tf_gfile = tf.gfile tf_placeholder = tf.placeholder tf_placeholder_with_default = tf.placeholder_with_default - extract_sub_graph = tf.graph_util.extract_sub_graph def inputs_without_resource(sess, input_names): @@ -709,11 +706,6 @@ def tf_optimize(input_names, output_names, graph_def): assert isinstance(input_names, list) assert isinstance(output_names, list) - # TODO: is this needed ? - needed_names = [utils.node_name(i) for i in input_names] + \ - [utils.node_name(i) for i in output_names] - graph_def = extract_sub_graph(graph_def, needed_names) - want_grappler = is_tf2() or Version(tf.__version__) >= Version("1.15") if want_grappler: graph_def = tf_optimize_grappler(input_names, output_names, graph_def)