@@ -465,7 +465,7 @@ def disable_asserts(input_string):
465
465
466
466
467
467
def replace_forceinline (input_string ):
468
- """__forceinline__'d methods can cause 'symbol multiply defined' errors in HIP.
468
+ """__forceinline__'d methods can cause 'symbol multiply defined' errors in HIP.
469
469
Adding 'static' to all such methods leads to compilation errors, so
470
470
replacing '__forceinline__' with 'inline' as a workaround
471
471
https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_faq.md#what-if-hip-generates-error-of-symbol-multiply-defined-only-on-amd-machine
@@ -681,9 +681,9 @@ def preprocessor(filepath, stats, hipify_caffe2):
681
681
682
682
if cuda_type in output_source :
683
683
if hipify_caffe2 :
684
- pattern = r'({0})' .format (cuda_type )
684
+ pattern = r'({0})' .format (re . escape ( cuda_type ) )
685
685
else :
686
- pattern = r'(\b{0}\b)' .format (cuda_type )
686
+ pattern = r'(\b{0}\b)' .format (re . escape ( cuda_type ) )
687
687
output_source = re .sub (pattern , hip_type , output_source )
688
688
689
689
# Perform Kernel Launch Replacements
@@ -706,7 +706,7 @@ def file_specific_replacement(filepath, search_string, replace_string, strict=Fa
706
706
with openf (filepath , "r+" ) as f :
707
707
contents = f .read ()
708
708
if strict :
709
- contents = re .sub (r'\b({0})\b' .format (search_string ), lambda x : replace_string , contents )
709
+ contents = re .sub (r'\b({0})\b' .format (re . escape ( search_string ) ), lambda x : replace_string , contents )
710
710
else :
711
711
contents = contents .replace (search_string , replace_string )
712
712
f .seek (0 )
@@ -824,7 +824,7 @@ def disable_unsupported_function_call(function, input_string, replacement):
824
824
output_string = input_string
825
825
826
826
# Find all calls to the function
827
- calls = re .finditer (r"\b{0}\b" .format (function ), input_string )
827
+ calls = re .finditer (r"\b{0}\b" .format (re . escape ( function ) ), input_string )
828
828
829
829
# Do replacements
830
830
for call in calls :
@@ -983,7 +983,7 @@ def replace_arg(match):
983
983
if "THCUNN" in filepath .split ("/" ) and "generic" not in filepath .split ("/" ):
984
984
kernel_name_with_template = kernel_name_with_template .replace ("<real>" , "<Dtype>" )
985
985
986
- full_new_kernel_launch = re .sub (r'\b{0}\b' .format (original_kernel_name_with_template ),
986
+ full_new_kernel_launch = re .sub (r'\b{0}\b' .format (re . escape ( original_kernel_name_with_template ) ),
987
987
lambda x : kernel_name_with_template , full_new_kernel_launch )
988
988
989
989
# Replace Launch
@@ -1181,7 +1181,7 @@ def main():
1181
1181
1182
1182
# Disable Constants w\ Boundary.
1183
1183
for const in constants :
1184
- txt = re .sub (r"\b{0}\b" .format (const ), constants [const ], txt )
1184
+ txt = re .sub (r"\b{0}\b" .format (re . escape ( const ) ), constants [const ], txt )
1185
1185
1186
1186
# Disable Constants
1187
1187
for s_const in s_constants :
0 commit comments