|
22 | 22 | from numba_dpcomp.mlir.settings import _readenv
|
23 | 23 | from numba_dpcomp import njit, jit, vectorize
|
24 | 24 |
|
| 25 | +from numba.core.registry import CPUDispatcher |
25 | 26 | from numba_dpcomp.mlir.passes import (
|
26 | 27 | print_pass_ir,
|
27 | 28 | get_print_buffer,
|
@@ -52,119 +53,103 @@ def _gen_tests():
|
52 | 53 | ]
|
53 | 54 |
|
54 | 55 | xfail_tests = {
|
55 |
| - "test_prange03sub", |
56 |
| - "test_prange03div", |
57 |
| - "test_prange07", |
58 |
| - "test_prange06", |
59 |
| - "test_prange12", |
60 |
| - "test_prange25", |
61 |
| - "test_prange18", |
62 |
| - "test_prange_nested_reduction1", |
63 |
| - "test_list_setitem_hoisting", |
64 |
| - "test_list_comprehension_prange", |
65 |
| - "test_prange_raises_invalid_step_size", |
66 |
| - "test_issue7501", |
67 |
| - "test_parfor_race_1", |
68 |
| - "test_nested_parfor_push_call_vars", |
69 |
| - "test_record_array_setitem_yield_array", |
70 |
| - "test_record_array_setitem", |
71 |
| - "test_multiple_call_getattr_object", |
72 |
| - "test_prange_two_instances_same_reduction_var", |
73 |
| - "test_prange_conflicting_reduction_ops", |
74 |
| - "test_ssa_false_reduction", |
75 |
| - "test_prange_two_conditional_reductions", |
76 |
| - "test_argument_alias_recarray_field", |
77 |
| - "test_mutable_list_param", |
78 |
| - "test_signed_vs_unsigned_vec_asm", |
79 |
| - "test_unsigned_refusal_to_vectorize", |
80 |
| - "test_vectorizer_fastmath_asm", |
81 |
| - "test_kde_example", |
82 |
| - "test_prange27", |
83 |
| - "test_simple09", |
84 |
| - "test_simple01", |
85 |
| - "test_simple10", |
86 |
| - "test_kmeans", |
87 |
| - "test_simple14", |
88 |
| - "test_simple04", |
89 |
| - "test_ndarray_fill", |
90 |
| - "test_fuse_argmin_argmax_max_min", |
91 |
| - "test_max", |
92 |
| - "test_arange", |
93 |
| - "test_min", |
94 |
| - "test_pi", |
95 |
| - "test_simple20", |
96 |
| - "test_simple24", |
97 |
| - "test_0d_array", |
98 |
| - "test_argmin", |
99 |
| - "test_simple07", |
100 |
| - "test_ndarray_fill2d", |
101 |
| - "test_argmax", |
102 |
| - "test_simple02", |
103 |
| - "test_simple18", |
104 |
| - "test_linspace", |
105 |
| - "test_std", |
106 |
| - "test_reshape_with_neg_one", |
107 |
| - "test_mvdot", |
108 |
| - "test_array_tuple_concat", |
109 |
| - "test_namedtuple1", |
110 |
| - "test_0d_broadcast", |
111 |
| - "test_var", |
112 |
| - "test_reshape_with_too_many_neg_one", |
113 |
| - "test_namedtuple2", |
114 |
| - "test_simple19", |
115 |
| - "test_no_hoisting_with_member_function_call", |
116 |
| - "test_parfor_dtype_type", |
117 |
| - "test_tuple3", |
118 |
| - "test_parfor_array_access3", |
119 |
| - "test_np_func_direct_import", |
120 |
| - "test_preparfor_canonicalize_kws", |
121 |
| - "test_parfor_array_access4", |
122 |
| - "test_tuple_concat_with_reverse_slice", |
123 |
| - "test_reduce", |
124 |
| - "test_two_d_array_reduction", |
125 |
| - "test_tuple_concat", |
126 |
| - "test_two_d_array_reduction_with_float_sizes", |
127 |
| - "test_reduction", |
128 |
| - "test_multiple_reduction_vars", |
129 |
| - "test_two_d_array_reduction_reuse", |
130 |
| - "test_parfor_slice21", |
131 |
| - "test_parfor_array_access_lower_slice", |
132 |
| - "test_size_assertion", |
133 |
| - "test_parfor_slice19", |
134 |
| - "test_parfor_slice23", |
135 |
| - "test_parfor_slice18", |
136 |
| - "test_parfor_slice20", |
137 |
| - "test_simple12", |
138 |
| - "test_parfor_slice2", |
139 |
| - "test_parfor_slice6", |
140 |
| - "test_parfor_slice22", |
141 |
| - "test_parfor_bitmask3", |
142 |
| - "test_simple13", |
143 |
| - "test_parfor_bitmask1", |
144 |
| - "test_parfor_bitmask4", |
145 |
| - "test_issue3169", |
146 |
| - "test_parfor_bitmask5", |
147 |
| - "test_issue3748", |
148 |
| - "test_parfor_bitmask6", |
149 |
| - "test_issue5001", |
150 |
| - "test_issue6774", |
151 |
| - "test_issue5167", |
152 |
| - "test_issue6095_numpy_max", |
153 |
| - "test_issue5065", |
154 |
| - "test_no_state_change_in_gufunc_lowering_on_error", |
155 |
| - "test_namedtuple3", |
156 |
| - "test_issue6102", |
157 |
| - "test_oversized_tuple_as_arg_to_kernel", |
158 |
| - "test_issue5942_2", |
159 |
| - "test_reshape_with_large_neg", |
160 |
| - "test_parfor_ufunc_typing", |
161 |
| - "test_issue_5098", |
162 |
| - "test_parfor_slice27", |
163 |
| - "test_ufunc_expr", |
164 |
| - "test_parfor_generate_fuse", |
165 |
| - "test_parfor_slice7", |
166 |
| - "test_parfor_bitmask2", |
167 |
| - "test_one_d_array_reduction", |
| 56 | + "test_prange03sub", # sub reduction |
| 57 | + "test_prange03div", # div reduction |
| 58 | + "test_prange25", # list support |
| 59 | + "test_prange18", # memssa failure |
| 60 | + "test_list_setitem_hoisting", # list support |
| 61 | + "test_list_comprehension_prange", # list comprehension support |
| 62 | + "test_prange_raises_invalid_step_size", # we actually support arbirary step in prange |
| 63 | + "test_issue7501", # invalid tensor<->memref canonicalization |
| 64 | + "test_parfor_race_1", # cfg->scf conversion failure |
| 65 | + "test_nested_parfor_push_call_vars", # Can't resolve function 'negative' |
| 66 | + "test_record_array_setitem_yield_array", # Record and string support |
| 67 | + "test_record_array_setitem", # Record and string support |
| 68 | + "test_multiple_call_getattr_object", # Can't resolve function 'negative' |
| 69 | + "test_prange_two_instances_same_reduction_var", # Non-trivial reduction |
| 70 | + "test_prange_conflicting_reduction_ops", # Conflicting reduction reduction check |
| 71 | + "test_ssa_false_reduction", # Frontend: object has no attribute 'name' |
| 72 | + "test_argument_alias_recarray_field", # Record support |
| 73 | + "test_mutable_list_param", # List support |
| 74 | + "test_signed_vs_unsigned_vec_asm", # Need to hook asm checks |
| 75 | + "test_unsigned_refusal_to_vectorize", # Need to hook asm checks |
| 76 | + "test_vectorizer_fastmath_asm", # Need to hook asm checks |
| 77 | + "test_kde_example", # List suport |
| 78 | + "test_prange27", # Literal return issue |
| 79 | + "test_simple01", # Empty shape not failed |
| 80 | + "test_kmeans", # List suport |
| 81 | + "test_simple14", # Slice shape mismatch |
| 82 | + "test_ndarray_fill", # array.fill |
| 83 | + "test_fuse_argmin_argmax_max_min", # numpy argmin, argmax |
| 84 | + "test_max", # max reduction |
| 85 | + "test_min", # min reduction |
| 86 | + "test_arange", # numpy.arange |
| 87 | + "test_pi", # np.random.ranf |
| 88 | + "test_simple20", # AssertionError not raised |
| 89 | + "test_simple24", # numpy.arange |
| 90 | + "test_0d_array", # numpy prod |
| 91 | + "test_argmin", # numpy.argmin |
| 92 | + "test_argmax", # numpy.argmax |
| 93 | + "test_simple07", # complex128 support |
| 94 | + "test_ndarray_fill2d", # array.fill |
| 95 | + "test_simple18", # np.linalg.svd |
| 96 | + "test_linspace", # np.linspace |
| 97 | + "test_std", # array.std |
| 98 | + "test_reshape_with_neg_one", # unsupported reshape |
| 99 | + "test_mvdot", # np.dot unsupported args |
| 100 | + "test_array_tuple_concat", # tuple concat |
| 101 | + "test_namedtuple1", # namedtuple support |
| 102 | + "test_0d_broadcast", # np.array |
| 103 | + "test_var", # array.var |
| 104 | + "test_reshape_with_too_many_neg_one", # unsupported reshape |
| 105 | + "test_namedtuple2", # namedtuple support |
| 106 | + "test_simple19", # np.dot unsupported args |
| 107 | + "test_no_hoisting_with_member_function_call", # set support |
| 108 | + "test_parfor_dtype_type", # dtype cast |
| 109 | + "test_tuple3", # numpy.arange |
| 110 | + "test_parfor_array_access3", # TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType' |
| 111 | + "test_preparfor_canonicalize_kws", # array.argsort |
| 112 | + "test_parfor_array_access4", # np.dot unsupported args |
| 113 | + "test_tuple_concat_with_reverse_slice", # enumerate |
| 114 | + "test_reduce", # functools.reduce |
| 115 | + "test_two_d_array_reduction", # np.arange |
| 116 | + "test_tuple_concat", # tuple concat |
| 117 | + "test_two_d_array_reduction_with_float_sizes", # np.array |
| 118 | + "test_two_d_array_reduction_reuse", # np.arange |
| 119 | + "test_parfor_slice21", # unsupported reshape |
| 120 | + "test_parfor_array_access_lower_slice", # np.arange |
| 121 | + "test_size_assertion", # AssertionError not raised |
| 122 | + "test_parfor_slice18", # np.arange |
| 123 | + "test_simple12", # complex128 |
| 124 | + "test_parfor_slice2", # AssertionError not raised |
| 125 | + "test_parfor_slice6", # array.transpose |
| 126 | + "test_parfor_slice22", # slice using array |
| 127 | + "test_simple13", # complex128 |
| 128 | + "test_parfor_bitmask1", # setitem with mask |
| 129 | + "test_parfor_bitmask2", # setitem with mask |
| 130 | + "test_parfor_bitmask3", # setitem with mask |
| 131 | + "test_parfor_bitmask4", # setitem with mask |
| 132 | + "test_parfor_bitmask5", # setitem with mask |
| 133 | + "test_parfor_bitmask6", # setitem with mask |
| 134 | + "test_issue3169", # list support |
| 135 | + "test_issue3748", # unituple of literal dynamic getitem |
| 136 | + "test_issue5001", # list suport |
| 137 | + "test_issue5167", # np.full |
| 138 | + "test_issue6095_numpy_max", # operand #1 does not dominate this use |
| 139 | + "test_issue5065", # tuple unpack |
| 140 | + "test_no_state_change_in_gufunc_lowering_on_error", # custom pipeline |
| 141 | + "test_namedtuple3", # namedtuple |
| 142 | + "test_issue6102", # list support |
| 143 | + "test_oversized_tuple_as_arg_to_kernel", # UnsupportedParforsError not raised |
| 144 | + "test_issue5942_2", # invalid result |
| 145 | + "test_reshape_with_large_neg", # unsupported reshape |
| 146 | + "test_parfor_ufunc_typing", # np.isinf |
| 147 | + "test_issue_5098", # list support and more |
| 148 | + "test_parfor_slice27", # Literal return issue |
| 149 | + "test_ufunc_expr", # np.bitwise_and( |
| 150 | + "test_parfor_generate_fuse", # operand #0 does not dominate this use |
| 151 | + "test_parfor_slice7", # array.transpose |
| 152 | + "test_one_d_array_reduction", # np.array |
168 | 153 | }
|
169 | 154 |
|
170 | 155 | skip_tests = {}
|
@@ -195,7 +180,11 @@ def wrapper(*args, **kwargs):
|
195 | 180 | res = njit(parallel=True)(func)(*args, **kwargs)
|
196 | 181 | ir = get_print_buffer()
|
197 | 182 | # Check some parallel loops were actually generated
|
198 |
| - assert ir.count("plier_util.parallel") > 0, ir |
| 183 | + if ir.count("plier_util.parallel") == 0: |
| 184 | + # In some cases we can canonicalize all loops away |
| 185 | + # Make sure no loops are present |
| 186 | + assert ir.count("scf.for") == 0, ir |
| 187 | + assert ir.count("scf.parallel") == 0, ir |
199 | 188 | return res
|
200 | 189 |
|
201 | 190 | return wrapper
|
@@ -240,6 +229,9 @@ def prange_tester(self, pyfunc, *args, **kwargs):
|
240 | 229 | return self._check_impl(pyfunc, *args, **kwargs)
|
241 | 230 |
|
242 | 231 | def check(self, pyfunc, *args, **kwargs):
|
| 232 | + if isinstance(pyfunc, CPUDispatcher): |
| 233 | + pyfunc = pyfunc.py_func |
| 234 | + |
243 | 235 | return self._check_impl(pyfunc, *args, **kwargs)
|
244 | 236 |
|
245 | 237 | def _check_impl(self, pyfunc, *args, **kwargs):
|
|
0 commit comments