Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions deepmd/utils/convert.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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='')
Expand All @@ -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`.
Expand Down Expand Up @@ -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)
fp.write(file_content)