@@ -167,11 +167,80 @@ def check_nd_call_func(
167
167
)
168
168
169
169
170
+ """
171
+ Below utility functions are required to keep backward compitibility
172
+ with DPC++ 2023.2 and dpctl 0.15.0. Otherwise we can't collect coverage report,
173
+ since DPC++ 2024.0 has the reported crash issue while running for coverage
174
+ and the latest dpctl (i.e. >0.15.0) can't be installed with DPC++ 2023.2.
175
+
176
+ TODO: remove the w/a once the above issue is resolved.
177
+ """
178
+
179
+
180
+ def _get_impl_fn (dpt_fn ):
181
+ if hasattr (dpt_fn , "get_implementation_function" ):
182
+ return dpt_fn .get_implementation_function ()
183
+
184
+ if hasattr (dpt_fn , "__name__" ):
185
+ if dpt_fn .__name__ == "UnaryElementwiseFunc" :
186
+ return dpt_fn .unary_fn_
187
+ elif dpt_fn .__name__ == "BinaryElementwiseFunc" :
188
+ return dpt_fn .binary_fn_
189
+
190
+ raise TypeError (
191
+ "Expected an instance of elementwise func class, but got {}" .format (
192
+ type (dpt_fn )
193
+ )
194
+ )
195
+
196
+
197
+ def _get_type_resolver_fn (dpt_fn ):
198
+ if hasattr (dpt_fn , "get_type_result_resolver_function" ):
199
+ return dpt_fn .get_type_result_resolver_function ()
200
+
201
+ if hasattr (dpt_fn , "result_type_resolver_fn_" ):
202
+ return dpt_fn .result_type_resolver_fn_
203
+
204
+ raise TypeError (
205
+ "Expected an instance of elementwise func class, but got {}" .format (
206
+ type (dpt_fn )
207
+ )
208
+ )
209
+
210
+
211
+ def _get_impl_inplace_fn (dpt_fn ):
212
+ if hasattr (dpt_fn , "get_implementation_inplace_function" ):
213
+ return dpt_fn .get_implementation_inplace_function ()
214
+
215
+ if hasattr (dpt_fn , "binary_inplace_fn_" ):
216
+ return dpt_fn .binary_inplace_fn_
217
+
218
+ raise TypeError (
219
+ "Expected an instance of elementwise func class, but got {}" .format (
220
+ type (dpt_fn )
221
+ )
222
+ )
223
+
224
+
225
+ def _get_type_promotion_fn (dpt_fn ):
226
+ if hasattr (dpt_fn , "get_type_promotion_path_acceptance_function" ):
227
+ return dpt_fn .get_type_promotion_path_acceptance_function ()
228
+
229
+ if hasattr (dpt_fn , "acceptance_fn_" ):
230
+ return dpt_fn .acceptance_fn_
231
+
232
+ raise TypeError (
233
+ "Expected an instance of elementwise func class, but got {}" .format (
234
+ type (dpt_fn )
235
+ )
236
+ )
237
+
238
+
170
239
def _make_unary_func (
171
240
name , dpt_unary_fn , fn_docstring , mkl_fn_to_call = None , mkl_impl_fn = None
172
241
):
173
- impl_fn = dpt_unary_fn . get_implementation_function ( )
174
- type_resolver_fn = dpt_unary_fn . get_type_result_resolver_function ( )
242
+ impl_fn = _get_impl_fn ( dpt_unary_fn )
243
+ type_resolver_fn = _get_type_resolver_fn ( dpt_unary_fn )
175
244
176
245
def _call_func (src , dst , sycl_queue , depends = None ):
177
246
"""A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""
@@ -193,10 +262,10 @@ def _call_func(src, dst, sycl_queue, depends=None):
193
262
def _make_binary_func (
194
263
name , dpt_binary_fn , fn_docstring , mkl_fn_to_call = None , mkl_impl_fn = None
195
264
):
196
- impl_fn = dpt_binary_fn . get_implementation_function ( )
197
- type_resolver_fn = dpt_binary_fn . get_type_result_resolver_function ( )
198
- inplce_fn = dpt_binary_fn . get_implementation_inplace_function ( )
199
- acceptance_fn = dpt_binary_fn . get_type_promotion_path_acceptance_function ( )
265
+ impl_fn = _get_impl_fn ( dpt_binary_fn )
266
+ type_resolver_fn = _get_type_resolver_fn ( dpt_binary_fn )
267
+ inplce_fn = _get_impl_inplace_fn ( dpt_binary_fn )
268
+ acceptance_fn = _get_type_promotion_fn ( dpt_binary_fn )
200
269
201
270
def _call_func (src1 , src2 , dst , sycl_queue , depends = None ):
202
271
"""A callback to register in UnaryElementwiseFunc class of dpctl.tensor"""
0 commit comments