From 3c26925d8dee34410b25793b992fc4ceadc4dfad Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 20:48:15 +0200 Subject: [PATCH 1/7] Updated get_ret_type_and_func takes sycl_device argument --- dpnp/dpnp_algo/dpnp_algo_statistics.pxi | 2 +- dpnp/dpnp_utils/dpnp_algo_utils.pxd | 4 ++-- dpnp/dpnp_utils/dpnp_algo_utils.pyx | 17 ++++++++++++----- dpnp/linalg/dpnp_algo_linalg.pyx | 10 +++++----- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo_statistics.pxi b/dpnp/dpnp_algo/dpnp_algo_statistics.pxi index 3ec3893c3acc..7106e91d47e7 100644 --- a/dpnp/dpnp_algo/dpnp_algo_statistics.pxi +++ b/dpnp/dpnp_algo/dpnp_algo_statistics.pxi @@ -265,7 +265,7 @@ cpdef utils.dpnp_descriptor dpnp_median(utils.dpnp_descriptor array1): array1_obj = array1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(array1_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(array1_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_statistic_1in_1out_func_ptr_t func = < custom_statistic_1in_1out_func_ptr_t > ret_type_and_func[1] diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pxd b/dpnp/dpnp_utils/dpnp_algo_utils.pxd index 7656d29bb15d..44232074524e 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pxd +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pxd @@ -163,8 +163,8 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2) Get common USM allocation in the form of (sycl_device, usm_type, sycl_queue) """ -cdef (DPNPFuncType, void *) get_ret_type_and_func(x1_obj, DPNPFuncData kernel_data) +cdef (DPNPFuncType, void *) get_ret_type_and_func(device, DPNPFuncData kernel_data) """ Get the corresponding return type and function pointer based on the -capability of the allocated input array device for the integer types. +capability of the allocated input array device. """ diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index db052be7827a..606bc7ee65de 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -663,13 +663,20 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2): return (common_sycl_queue.sycl_device, common_usm_type, common_sycl_queue) -cdef (DPNPFuncType, void *) get_ret_type_and_func(x1_obj, DPNPFuncData kernel_data): - if dpnp.issubdtype(x1_obj.dtype, dpnp.integer) and not x1_obj.sycl_device.has_aspect_fp64: +cdef (DPNPFuncType, void *) get_ret_type_and_func(device, DPNPFuncData kernel_data): + """ + This function is responsible for determining the appropriate return type + and function pointer based on the capability of the allocated input array device + for integer types and its definition. + """ + return_type = kernel_data.return_type + func = kernel_data.ptr + + if kernel_data.ptr_no_fp64 != NULL and not device.has_aspect_fp64: + return_type = kernel_data.return_type_no_fp64 func = kernel_data.ptr_no_fp64 - else: - return_type = kernel_data.return_type - func = kernel_data.ptr + return return_type, func diff --git a/dpnp/linalg/dpnp_algo_linalg.pyx b/dpnp/linalg/dpnp_algo_linalg.pyx index e6484599c51e..7751fa24885c 100644 --- a/dpnp/linalg/dpnp_algo_linalg.pyx +++ b/dpnp/linalg/dpnp_algo_linalg.pyx @@ -196,7 +196,7 @@ cpdef tuple dpnp_eig(utils.dpnp_descriptor x1): x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_2in_1out_func_ptr_t func = < custom_linalg_2in_1out_func_ptr_t > ret_type_and_func[1] @@ -242,7 +242,7 @@ cpdef utils.dpnp_descriptor dpnp_eigvals(utils.dpnp_descriptor input): input_obj = input.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_1out_with_size_func_ptr_t_ func = < custom_linalg_1in_1out_with_size_func_ptr_t_ > ret_type_and_func[1] @@ -281,7 +281,7 @@ cpdef utils.dpnp_descriptor dpnp_inv(utils.dpnp_descriptor input): input_obj = input.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_1out_func_ptr_t func = < custom_linalg_1in_1out_func_ptr_t > ret_type_and_func[1] @@ -462,7 +462,7 @@ cpdef tuple dpnp_qr(utils.dpnp_descriptor x1, str mode): x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_3out_shape_t func = < custom_linalg_1in_3out_shape_t > ret_type_and_func[1] @@ -515,7 +515,7 @@ cpdef tuple dpnp_svd(utils.dpnp_descriptor x1, cpp_bool full_matrices, cpp_bool x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_3out_shape_t func = < custom_linalg_1in_3out_shape_t > ret_type_and_func[1] From f2aa954ee0a97cc0d513367aa580971dfc3e5952 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 20:54:40 +0200 Subject: [PATCH 2/7] Use get_ret_type_and_func in call_fptr_1in_1out_strides --- dpnp/dpnp_algo/dpnp_algo.pyx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo.pyx b/dpnp/dpnp_algo/dpnp_algo.pyx index e60834599a7d..28258d0b56e5 100644 --- a/dpnp/dpnp_algo/dpnp_algo.pyx +++ b/dpnp/dpnp_algo/dpnp_algo.pyx @@ -348,7 +348,13 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name, """ get the FPTR data structure """ cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, param1_type, param1_type) - result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type) + x1_obj = x1.get_array() + + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) + cdef DPNPFuncType return_type = ret_type_and_func[0] + cdef fptr_1in_1out_strides_t func = < fptr_1in_1out_strides_t > ret_type_and_func[1] + + result_type = dpnp_DPNPFuncType_to_dtype( < size_t > return_type) cdef shape_type_c x1_shape = x1.shape cdef shape_type_c x1_strides = utils.strides_to_vector(x1.strides, x1_shape) @@ -358,9 +364,8 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name, if out is None: """ Create result array with type given by FPTR data """ - x1_obj = x1.get_array() result = utils.create_output_descriptor(result_shape, - kernel_data.return_type, + return_type, None, device=x1_obj.sycl_device, usm_type=x1_obj.usm_type, @@ -383,7 +388,6 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name, cdef shape_type_c result_strides = utils.strides_to_vector(result.strides, result_shape) """ Call FPTR function """ - cdef fptr_1in_1out_strides_t func = kernel_data.ptr cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref, result.get_data(), result.size, From a61284d0c3351abb781216c260c45431b5224150 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 21:00:31 +0200 Subject: [PATCH 3/7] Use get_ret_type_and_func in call_fptr_2in_1out --- dpnp/dpnp_algo/dpnp_algo.pyx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo.pyx b/dpnp/dpnp_algo/dpnp_algo.pyx index 28258d0b56e5..92b8d2cdbcef 100644 --- a/dpnp/dpnp_algo/dpnp_algo.pyx +++ b/dpnp/dpnp_algo/dpnp_algo.pyx @@ -423,7 +423,13 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name, # get the FPTR data structure cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, x1_c_type, x2_c_type) - result_type = dpnp_DPNPFuncType_to_dtype( < size_t > kernel_data.return_type) + result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) + + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(result_sycl_device, kernel_data) + cdef DPNPFuncType return_type = ret_type_and_func[0] + cdef fptr_2in_1out_t func = < fptr_2in_1out_t > ret_type_and_func[1] + + result_type = dpnp_DPNPFuncType_to_dtype( < size_t > return_type) # Create result array cdef shape_type_c x1_shape = x1_obj.shape @@ -431,12 +437,10 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name, cdef shape_type_c result_shape = utils.get_common_shape(x1_shape, x2_shape) cdef utils.dpnp_descriptor result - result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) - if out is None: """ Create result array with type given by FPTR data """ result = utils.create_output_descriptor(result_shape, - kernel_data.return_type, + return_type, None, device=result_sycl_device, usm_type=result_usm_type, @@ -455,7 +459,6 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name, cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref() """ Call FPTR function """ - cdef fptr_2in_1out_t func = kernel_data.ptr cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref, result.get_data(), x1_obj.get_data(), From 98729f60e473e5d9b25c6f2e743dc13fde2df546 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 21:03:05 +0200 Subject: [PATCH 4/7] Fix docstrings --- dpnp/dpnp_utils/dpnp_algo_utils.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index 606bc7ee65de..b6bfa594d2c4 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -666,8 +666,7 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2): cdef (DPNPFuncType, void *) get_ret_type_and_func(device, DPNPFuncData kernel_data): """ This function is responsible for determining the appropriate return type - and function pointer based on the capability of the allocated input array device - for integer types and its definition. + and function pointer based on the capability of the allocated input array device. """ return_type = kernel_data.return_type func = kernel_data.ptr From fa30d7d1c427a7537076665d028e660754c790ed Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 21:07:56 +0200 Subject: [PATCH 5/7] Use get_ret_type_and_func in call_fptr_2in_1out_strides --- dpnp/dpnp_algo/dpnp_algo.pyx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo.pyx b/dpnp/dpnp_algo/dpnp_algo.pyx index 92b8d2cdbcef..af7efbe63e40 100644 --- a/dpnp/dpnp_algo/dpnp_algo.pyx +++ b/dpnp/dpnp_algo/dpnp_algo.pyx @@ -350,6 +350,7 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name, x1_obj = x1.get_array() + # get FPTR function and return type cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef fptr_1in_1out_strides_t func = < fptr_1in_1out_strides_t > ret_type_and_func[1] @@ -425,6 +426,7 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name, result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) + # get FPTR function and return type cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(result_sycl_device, kernel_data) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef fptr_2in_1out_t func = < fptr_2in_1out_t > ret_type_and_func[1] @@ -492,6 +494,13 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out_strides(DPNPFuncName fptr_name, # get the FPTR data structure cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, x1_c_type, x2_c_type) + result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) + + # get FPTR function and return type + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(result_sycl_device, kernel_data) + cdef DPNPFuncType return_type = ret_type_and_func[0] + cdef fptr_2in_1out_strides_t func = < fptr_2in_1out_strides_t > ret_type_and_func[1] + # Create result array cdef shape_type_c x1_shape = x1_obj.shape @@ -502,12 +511,6 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out_strides(DPNPFuncName fptr_name, cdef shape_type_c result_shape = utils.get_common_shape(x1_shape, x2_shape) cdef utils.dpnp_descriptor result - result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) - - # get FPTR function and return type - cdef fptr_2in_1out_strides_t func = < fptr_2in_1out_strides_t > kernel_data.ptr - cdef DPNPFuncType return_type = kernel_data.return_type - # check 'out' parameter data if out is not None: if out.shape != result_shape: From 8f596f4bf525cac246a726811c50f819c2513bbe Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Tue, 25 Jul 2023 21:37:19 +0200 Subject: [PATCH 6/7] Use dpnp.result_type in dpnp_cov instead of dpt.result_type --- dpnp/dpnp_utils/dpnp_utils_statistics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dpnp/dpnp_utils/dpnp_utils_statistics.py b/dpnp/dpnp_utils/dpnp_utils_statistics.py index e8ccb1794682..9d69dbaa3684 100644 --- a/dpnp/dpnp_utils/dpnp_utils_statistics.py +++ b/dpnp/dpnp_utils/dpnp_utils_statistics.py @@ -79,8 +79,8 @@ def _get_2dmin_array(x, dtype): dtypes = [m.dtype, dpnp.default_float_type(sycl_queue=queue)] if y is not None: dtypes.append(y.dtype) - dtype = dpt.result_type(*dtypes) - # TODO: remove when dpctl.result_type() is fixed + dtype = dpnp.result_type(*dtypes) + # TODO: remove when dpctl.result_type() is returned dtype based on fp64 fp64 = queue.sycl_device.has_aspect_fp64 if not fp64: if dtype == dpnp.float64: From 68001756529780c36c6781af4aa40b8be24494c1 Mon Sep 17 00:00:00 2001 From: Vladislav Perevezentsev Date: Wed, 26 Jul 2023 12:00:18 +0200 Subject: [PATCH 7/7] Updated get_ret_type_and_func takes cpp_bool has_aspect_fp64 instead of device agrument --- dpnp/dpnp_algo/dpnp_algo.pyx | 9 ++++++--- dpnp/dpnp_algo/dpnp_algo_statistics.pxi | 3 ++- dpnp/dpnp_utils/dpnp_algo_utils.pxd | 5 +++-- dpnp/dpnp_utils/dpnp_algo_utils.pyx | 7 ++++--- dpnp/linalg/dpnp_algo_linalg.pyx | 15 ++++++++++----- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dpnp/dpnp_algo/dpnp_algo.pyx b/dpnp/dpnp_algo/dpnp_algo.pyx index af7efbe63e40..89ce50169c87 100644 --- a/dpnp/dpnp_algo/dpnp_algo.pyx +++ b/dpnp/dpnp_algo/dpnp_algo.pyx @@ -351,7 +351,8 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name, x1_obj = x1.get_array() # get FPTR function and return type - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + x1_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef fptr_1in_1out_strides_t func = < fptr_1in_1out_strides_t > ret_type_and_func[1] @@ -427,7 +428,8 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name, result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) # get FPTR function and return type - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(result_sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + result_sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef fptr_2in_1out_t func = < fptr_2in_1out_t > ret_type_and_func[1] @@ -497,7 +499,8 @@ cdef utils.dpnp_descriptor call_fptr_2in_1out_strides(DPNPFuncName fptr_name, result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj) # get FPTR function and return type - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(result_sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + result_sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef fptr_2in_1out_strides_t func = < fptr_2in_1out_strides_t > ret_type_and_func[1] diff --git a/dpnp/dpnp_algo/dpnp_algo_statistics.pxi b/dpnp/dpnp_algo/dpnp_algo_statistics.pxi index 7106e91d47e7..1c35cb4ac337 100644 --- a/dpnp/dpnp_algo/dpnp_algo_statistics.pxi +++ b/dpnp/dpnp_algo/dpnp_algo_statistics.pxi @@ -265,7 +265,8 @@ cpdef utils.dpnp_descriptor dpnp_median(utils.dpnp_descriptor array1): array1_obj = array1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(array1_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + array1_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_statistic_1in_1out_func_ptr_t func = < custom_statistic_1in_1out_func_ptr_t > ret_type_and_func[1] diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pxd b/dpnp/dpnp_utils/dpnp_algo_utils.pxd index 44232074524e..b7c739dcfbb9 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pxd +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pxd @@ -163,8 +163,9 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2) Get common USM allocation in the form of (sycl_device, usm_type, sycl_queue) """ -cdef (DPNPFuncType, void *) get_ret_type_and_func(device, DPNPFuncData kernel_data) +cdef (DPNPFuncType, void *) get_ret_type_and_func(DPNPFuncData kernel_data, + cpp_bool has_aspect_fp64) """ Get the corresponding return type and function pointer based on the -capability of the allocated input array device. +capability of the allocated result array device. """ diff --git a/dpnp/dpnp_utils/dpnp_algo_utils.pyx b/dpnp/dpnp_utils/dpnp_algo_utils.pyx index b6bfa594d2c4..f88b42bde7f1 100644 --- a/dpnp/dpnp_utils/dpnp_algo_utils.pyx +++ b/dpnp/dpnp_utils/dpnp_algo_utils.pyx @@ -663,15 +663,16 @@ cdef tuple get_common_usm_allocation(dpnp_descriptor x1, dpnp_descriptor x2): return (common_sycl_queue.sycl_device, common_usm_type, common_sycl_queue) -cdef (DPNPFuncType, void *) get_ret_type_and_func(device, DPNPFuncData kernel_data): +cdef (DPNPFuncType, void *) get_ret_type_and_func(DPNPFuncData kernel_data, + cpp_bool has_aspect_fp64): """ This function is responsible for determining the appropriate return type - and function pointer based on the capability of the allocated input array device. + and function pointer based on the capability of the allocated result array device. """ return_type = kernel_data.return_type func = kernel_data.ptr - if kernel_data.ptr_no_fp64 != NULL and not device.has_aspect_fp64: + if kernel_data.ptr_no_fp64 != NULL and not has_aspect_fp64: return_type = kernel_data.return_type_no_fp64 func = kernel_data.ptr_no_fp64 diff --git a/dpnp/linalg/dpnp_algo_linalg.pyx b/dpnp/linalg/dpnp_algo_linalg.pyx index 7751fa24885c..39ba81bac593 100644 --- a/dpnp/linalg/dpnp_algo_linalg.pyx +++ b/dpnp/linalg/dpnp_algo_linalg.pyx @@ -196,7 +196,8 @@ cpdef tuple dpnp_eig(utils.dpnp_descriptor x1): x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + x1_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_2in_1out_func_ptr_t func = < custom_linalg_2in_1out_func_ptr_t > ret_type_and_func[1] @@ -242,7 +243,8 @@ cpdef utils.dpnp_descriptor dpnp_eigvals(utils.dpnp_descriptor input): input_obj = input.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + input_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_1out_with_size_func_ptr_t_ func = < custom_linalg_1in_1out_with_size_func_ptr_t_ > ret_type_and_func[1] @@ -281,7 +283,8 @@ cpdef utils.dpnp_descriptor dpnp_inv(utils.dpnp_descriptor input): input_obj = input.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(input_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + input_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_1out_func_ptr_t func = < custom_linalg_1in_1out_func_ptr_t > ret_type_and_func[1] @@ -462,7 +465,8 @@ cpdef tuple dpnp_qr(utils.dpnp_descriptor x1, str mode): x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + x1_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_3out_shape_t func = < custom_linalg_1in_3out_shape_t > ret_type_and_func[1] @@ -515,7 +519,8 @@ cpdef tuple dpnp_svd(utils.dpnp_descriptor x1, cpp_bool full_matrices, cpp_bool x1_obj = x1.get_array() - cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(x1_obj.sycl_device, kernel_data) + cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data, + x1_obj.sycl_device.has_aspect_fp64) cdef DPNPFuncType return_type = ret_type_and_func[0] cdef custom_linalg_1in_3out_shape_t func = < custom_linalg_1in_3out_shape_t > ret_type_and_func[1]