2424# THE SOFTWARE.
2525"""
2626
27- from __future__ import absolute_import , division , print_function
2827
2928import fnmatch
3029import os
@@ -37,7 +36,7 @@ class InputError(Exception):
3736 # Exception raised for errors in the input.
3837
3938 def __init__ (self , message ):
40- super (InputError , self ).__init__ (message )
39+ super ().__init__ (message )
4140 self .message = message
4241
4342 def __str__ (self ):
@@ -128,8 +127,8 @@ def add_dim3(kernel_string, cuda_kernel):
128127 .strip (" " )
129128 )
130129
131- first_arg_dim3 = "dim3({})" . format ( first_arg_clean )
132- second_arg_dim3 = "dim3({})" . format ( second_arg_clean )
130+ first_arg_dim3 = f "dim3({ first_arg_clean } )"
131+ second_arg_dim3 = f "dim3({ second_arg_clean } )"
133132
134133 first_arg_raw_dim3 = first_arg_raw .replace (first_arg_clean , first_arg_dim3 )
135134 second_arg_raw_dim3 = second_arg_raw .replace (second_arg_clean , second_arg_dim3 )
@@ -145,9 +144,7 @@ def add_dim3(kernel_string, cuda_kernel):
145144def processKernelLaunches (string ):
146145 """Replace the CUDA style Kernel launches with the HIP style kernel launches."""
147146 # Concat the namespace with the kernel names. (Find cleaner way of doing this later).
148- string = RE_KERNEL_LAUNCH .sub (
149- lambda inp : "{0}{1}::" .format (inp .group (1 ), inp .group (2 )), string
150- )
147+ string = RE_KERNEL_LAUNCH .sub (lambda inp : f"{ inp .group (1 )} { inp .group (2 )} ::" , string )
151148
152149 def grab_method_and_template (in_kernel ):
153150 # The positions for relevant kernel components.
@@ -388,7 +385,7 @@ def sub_repl(m):
388385def preprocessor (project_directory , output_directory , filepath ):
389386 """Executes the CUDA -> HIP conversion on the specified file."""
390387 fin_path = os .path .join (project_directory , filepath )
391- with open (fin_path , "r" ) as fin :
388+ with open (fin_path ) as fin :
392389 output_source = fin .read ()
393390
394391 fout_path = os .path .join (output_directory , get_hip_file_path (filepath ))
0 commit comments