From 98a33ab34647dd4edee8866b65b5a582458abbbc Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 23 Aug 2022 03:39:26 -0400 Subject: [PATCH] replace FastGFile with GFile FastGFile throws a deprecated warning. See https://github.com/tensorflow/tensorflow/blob/d8ce9f9c301d021a69953134185ab728c1c248d3/tensorflow/python/platform/gfile.py#L128 Signed-off-by: Jinzhe Zeng --- deepmd/utils/convert.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/deepmd/utils/convert.py b/deepmd/utils/convert.py index 7dc8ebb06f..bbe9e067ef 100644 --- a/deepmd/utils/convert.py +++ b/deepmd/utils/convert.py @@ -1,7 +1,6 @@ import os from deepmd.env import tf from google.protobuf import text_format -from tensorflow.python.platform import gfile def convert_13_to_21(input_model: str, output_model: str): @@ -132,7 +131,7 @@ def convert_pb_to_pbtxt(pbfile: str, pbtxtfile: str): pbtxtfile : str filename of the output graph text """ - with gfile.FastGFile(pbfile, 'rb') as f: + with tf.gfile.GFile(pbfile, 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) tf.import_graph_def(graph_def, name='') @@ -148,7 +147,7 @@ def convert_pbtxt_to_pb(pbtxtfile: str, pbfile: str): pbfile : str filename of the output graph """ - with tf.gfile.FastGFile(pbtxtfile, 'r') as f: + with tf.gfile.GFile(pbtxtfile, 'r') as f: graph_def = tf.GraphDef() file_content = f.read() # Merges the human-readable string in `file_content` into `graph_def`. @@ -331,4 +330,4 @@ def convert_dp20_to_dp21(fname: str): .replace('TabulateFusionGrad', 'TabulateFusionSeAGrad')\ .replace('TabulateFusionGradGrad', 'TabulateFusionSeAGradGrad') with open(fname, 'w') as fp: - fp.write(file_content) \ No newline at end of file + fp.write(file_content)