@@ -118,7 +118,7 @@ def prepare_list_of_files(self, kernel_name, params, grid, threads, block_size_n
118
118
The files beyond the first are considered additional files that may also contain tunable parameters
119
119
120
120
For each file beyond the first this function creates a temporary file with
121
- preprocessors statements inserted. Occurences of the original filenames in the
121
+ preprocessors statements inserted. Occurrences of the original filenames in the
122
122
first file are replaced with their temporary counterparts.
123
123
124
124
:param kernel_name: A string specifying the kernel name.
@@ -174,7 +174,7 @@ def prepare_list_of_files(self, kernel_name, params, grid, threads, block_size_n
174
174
temp_file = util .get_temp_filename (suffix = "." + f .split ("." )[- 1 ])
175
175
temp_files [f ] = temp_file
176
176
util .write_file (temp_file , ks )
177
- # replace occurences of the additional file's name in the first kernel_string with the name of the temp file
177
+ # replace occurrences of the additional file's name in the first kernel_string with the name of the temp file
178
178
kernel_string = kernel_string .replace (f , temp_file )
179
179
180
180
return name , kernel_string , temp_files
@@ -574,7 +574,7 @@ def compile_and_benchmark(self, kernel_source, gpu_args, params, kernel_options,
574
574
if kernel_options .texmem_args is not None :
575
575
self .dev .copy_texture_memory_args (kernel_options .texmem_args )
576
576
577
- # stop compilation stopwatch and convert to miliseconds
577
+ # stop compilation stopwatch and convert to milliseconds
578
578
last_compilation_time = 1000 * (time .perf_counter () - start_compilation )
579
579
580
580
# test kernel for correctness
@@ -600,7 +600,7 @@ def compile_and_benchmark(self, kernel_source, gpu_args, params, kernel_options,
600
600
print ("Error while compiling or benchmarking, see source files: " + " " .join (temp_filenames ))
601
601
raise e
602
602
603
- # clean up any temporary files, if no error occured
603
+ # clean up any temporary files, if no error occurred
604
604
instance .delete_temp_files ()
605
605
606
606
result ["compile_time" ] = last_compilation_time or 0
@@ -776,10 +776,12 @@ def _default_verify_function(instance, answer, result_host, atol, verbose):
776
776
# for each element in the argument list, check if the types match
777
777
for i , arg in enumerate (instance .arguments ):
778
778
if answer [i ] is not None : # skip None elements in the answer list
779
- if isinstance (answer [i ], (np .ndarray , cp .ndarray )) and isinstance (arg , (np .ndarray , cp .ndarray )):
780
- if answer [i ].dtype != arg .dtype :
779
+ if isinstance (answer [i ], (np .ndarray , cp .ndarray )) and isinstance (
780
+ arg , (np .ndarray , cp .ndarray )
781
+ ):
782
+ if not np .can_cast (arg .dtype , answer [i ].dtype ):
781
783
raise TypeError (
782
- f"Element { i } of the expected results list is not of the same dtype as the kernel output: "
784
+ f"Element { i } of the expected results list has a dtype that is not compatible with the dtype of the kernel output: "
783
785
+ str (answer [i ].dtype )
784
786
+ " != "
785
787
+ str (arg .dtype )
@@ -857,9 +859,18 @@ def _flatten(a):
857
859
output_test = np .allclose (expected , result , atol = atol )
858
860
859
861
if not output_test and verbose :
860
- print ("Error: " + util .get_config_string (instance .params ) + " detected during correctness check" )
861
- print ("this error occured when checking value of the %oth kernel argument" % (i ,))
862
- print ("Printing kernel output and expected result, set verbose=False to suppress this debug print" )
862
+ print (
863
+ "Error: "
864
+ + util .get_config_string (instance .params )
865
+ + " detected during correctness check"
866
+ )
867
+ print (
868
+ "this error occurred when checking value of the %oth kernel argument"
869
+ % (i ,)
870
+ )
871
+ print (
872
+ "Printing kernel output and expected result, set verbose=False to suppress this debug print"
873
+ )
863
874
np .set_printoptions (edgeitems = 50 )
864
875
print ("Kernel output:" )
865
876
print (result )
@@ -901,7 +912,7 @@ def replace_typename_token(matchobj):
901
912
# if the templated typename occurs as a token in the string, meaning that it is enclosed in
902
913
# beginning of string or whitespace, and end of string, whitespace or star
903
914
regex = r"(^|\s+)(" + k + r")($|\s+|\*)"
904
- sub = re .sub (regex , replace_typename_token , arg_type , re .S )
915
+ sub = re .sub (regex , replace_typename_token , arg_type , flags = re .S )
905
916
type_list [i ] = sub
906
917
907
918
0 commit comments