Skip to content

Commit

Permalink
fix decoding error when clip grad op and python==2 (#33937)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiweibo committed Jul 5, 2021
1 parent 00c85a7 commit c661783
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tools/remove_grad_op_and_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys
import re
import glob
import io


def find_type_files(cur_dir, file_type, file_list=[]):
Expand Down Expand Up @@ -124,7 +125,7 @@ def update_operator_cmake(cmake_file):
custom_pattern2 = custom_pattern2[:-1]

all_matches = []
with open(op_file, 'r', encoding='utf-8') as f:
with io.open(op_file, 'r', encoding='utf-8') as f:
content = ''.join(f.readlines())

op, op_count = remove_grad_op_and_kernel(content, op_pattern1,
Expand Down Expand Up @@ -157,8 +158,8 @@ def update_operator_cmake(cmake_file):
for i in all_matches:
content = content.replace(i, '')

with open(op_file, 'w') as f:
f.write(content)
with io.open(op_file, 'w', encoding='utf-8') as f:
f.write(u'{}'.format(content))

# 2. update operators/CMakeLists.txt
cmake_file = os.path.join(tool_dir,
Expand Down

0 comments on commit c661783

Please sign in to comment.