From d655c695eaac4129119b4d577f5d0d0564ba382d Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Mon, 28 Aug 2023 11:26:49 -0500 Subject: [PATCH 1/6] SAT-6118 Get rid of fallback on numpy in dpnp.asfarray --- dpnp/dpnp_iface_manipulation.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index a7ce7fb560e..33b4e077d44 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -89,18 +89,13 @@ def asfarray(a, dtype=None): """ - a_desc = dpnp.get_dpnp_descriptor(a, copy_when_nondefault_queue=False) - if a_desc: - if dtype is None or not numpy.issubdtype(dtype, dpnp.inexact): + if dtype is None or not numpy.issubdtype(dtype, dpnp.inexact): + if dpnp.is_supported_array_type(a): dtype = dpnp.default_float_type(sycl_queue=a.sycl_queue) + else: + dtype = dpnp.default_float_type() - # if type is the same then same object should be returned - if a_desc.dtype == dtype: - return a - - return array(a, dtype=dtype) - - return call_origin(numpy.asfarray, a, dtype) + return array(a, dtype=dtype) def atleast_1d(*arys): From 3a9292bd4199486aa32256fbaa17b24beb847284 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Tue, 29 Aug 2023 10:58:19 -0500 Subject: [PATCH 2/6] Added nore test for dpnp.asfarray() function. --- dpnp/dpnp_iface_manipulation.py | 37 +++-- tests/skipped_tests.tbl | 9 ++ tests/skipped_tests_gpu.tbl | 9 ++ tests/test_arraymanipulation.py | 1 - tests/test_sycl_queue.py | 9 +- tests/test_usm_type.py | 9 +- .../cupy/manipulation_tests/test_kind.py | 126 ++++++++++++++++++ 7 files changed, 187 insertions(+), 13 deletions(-) create mode 100644 tests/third_party/cupy/manipulation_tests/test_kind.py diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 33b4e077d44..f15edcd35bf 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -46,7 +46,6 @@ import dpnp from dpnp.dpnp_algo import * from dpnp.dpnp_array import dpnp_array -from dpnp.dpnp_iface_arraycreation import array from dpnp.dpnp_utils import * __all__ = [ @@ -75,7 +74,7 @@ ] -def asfarray(a, dtype=None): +def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None): """ Return an array converted to a float type. @@ -83,19 +82,37 @@ def asfarray(a, dtype=None): Notes ----- - This function works exactly the same as :obj:`dpnp.array`. - If dtype is `None`, `bool` or one of the `int` dtypes, it is replaced with - the default floating type in DPNP depending on device capabilities. + If `dtype` is ``None``, :obj:`dpnp.bool` or one of the `int` dtypes, + it is replaced with the default floating type (:obj:`dpnp.float64` + if a device supports it, or :obj:`dpnp.float32` type otherwise). + + Returns + ------- + y : dpnp.ndarray + The input a as a float ndarray. + + Examples + -------- + >>> import dpnp as np + >>> np.asfarray([2, 3]) + array([2., 3.]) + >>> np.asfarray([2, 3], dtype='float') + array([2., 3.]) + >>> np.asfarray([2, 3], dtype='int8') + array([2., 3.]) """ + _sycl_queue = dpnp.get_normalized_queue_device( + a, sycl_queue=sycl_queue, device=device + ) + if dtype is None or not numpy.issubdtype(dtype, dpnp.inexact): - if dpnp.is_supported_array_type(a): - dtype = dpnp.default_float_type(sycl_queue=a.sycl_queue) - else: - dtype = dpnp.default_float_type() + dtype = dpnp.default_float_type(sycl_queue=_sycl_queue) - return array(a, dtype=dtype) + return dpnp.array( + a, dtype=dtype, copy=False, usm_type=usm_type, sycl_queue=_sycl_queue + ) def atleast_1d(*arys): diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index 60e9893ef69..8f652e49bfd 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -489,6 +489,15 @@ tests/third_party/cupy/manipulation_tests/test_shape.py::TestRavel::test_ravel tests/third_party/cupy/manipulation_tests/test_shape.py::TestReshape::test_reshape_zerosize tests/third_party/cupy/manipulation_tests/test_shape.py::TestReshape::test_reshape_zerosize2 +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite_non_finite_vals +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_C_and_F_flags +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_empty_requirements +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_flag_check +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_dtype +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_requirments +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_owndata + tests/third_party/cupy/manipulation_tests/test_tiling.py::TestRepeatRepeatsNdarray::test_func tests/third_party/cupy/manipulation_tests/test_tiling.py::TestRepeatRepeatsNdarray::test_method tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTileFailure_param_0_{reps=-1}::test_tile_failure diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index ade729c95cd..fc2618ea420 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -647,6 +647,15 @@ tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_3_{reps tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_4_{reps=(2, 3)}::test_array_tile tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_5_{reps=(2, 3, 4, 5)}::test_array_tile +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite_non_finite_vals +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_C_and_F_flags +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_empty_requirements +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_flag_check +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_dtype +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_requirments +tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_owndata + tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_3_{name='angle', nargs=1}::test_raises_with_numpy_input tests/third_party/cupy/math_tests/test_explog.py::TestExplog::test_logaddexp diff --git a/tests/test_arraymanipulation.py b/tests/test_arraymanipulation.py index 94f54accbc7..d18b8ed0cca 100644 --- a/tests/test_arraymanipulation.py +++ b/tests/test_arraymanipulation.py @@ -13,7 +13,6 @@ from .helper import get_all_dtypes, get_float_complex_dtypes -@pytest.mark.usefixtures("allow_fall_back_on_numpy") @pytest.mark.parametrize("dtype", get_all_dtypes()) @pytest.mark.parametrize( "data", [[1, 2, 3], [1.0, 2.0, 3.0]], ids=["[1, 2, 3]", "[1., 2., 3.]"] diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index 96bd5b60a8c..ddb9b3a0498 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -1015,7 +1015,14 @@ def test_to_device(device_from, device_to): ) @pytest.mark.parametrize( "func", - ["array", "asarray", "asanyarray", "ascontiguousarray", "asfortranarray"], + [ + "array", + "asarray", + "asanyarray", + "ascontiguousarray", + "asfarray", + "asfortranarray", + ], ) @pytest.mark.parametrize( "device_param", ["", "None", "sycl_device"], ids=["Empty", "None", "device"] diff --git a/tests/test_usm_type.py b/tests/test_usm_type.py index ee01339001c..53037129b18 100644 --- a/tests/test_usm_type.py +++ b/tests/test_usm_type.py @@ -159,7 +159,14 @@ def test_array_creation(func, args, usm_type_x, usm_type_y): @pytest.mark.parametrize( "func", - ["array", "asarray", "asanyarray", "ascontiguousarray", "asfortranarray"], + [ + "array", + "asarray", + "asanyarray", + "ascontiguousarray", + "asfarray", + "asfortranarray", + ], ) @pytest.mark.parametrize("usm_type_x", list_of_usm_types, ids=list_of_usm_types) @pytest.mark.parametrize("usm_type_y", list_of_usm_types, ids=list_of_usm_types) diff --git a/tests/third_party/cupy/manipulation_tests/test_kind.py b/tests/third_party/cupy/manipulation_tests/test_kind.py new file mode 100644 index 00000000000..2d1ba7e5c64 --- /dev/null +++ b/tests/third_party/cupy/manipulation_tests/test_kind.py @@ -0,0 +1,126 @@ +import unittest + +import numpy +import pytest + +import dpnp as cupy +from tests.third_party.cupy import testing + + +class TestKind(unittest.TestCase): + @testing.for_orders("CFAK") + @testing.for_all_dtypes() + @testing.numpy_cupy_array_equal() + def test_asarray_chkfinite(self, xp, dtype, order): + a = [0, 4, 0, 5] + return xp.asarray_chkfinite(a, dtype=dtype, order=order) + + @testing.for_orders("CFAK") + @testing.for_all_dtypes(no_bool=True) + def test_asarray_chkfinite_non_finite_vals(self, dtype, order): + a = [-numpy.inf, 0.0, numpy.inf, numpy.nan] + for xp in (numpy, cupy): + if xp.issubdtype(dtype, xp.integer): + error = OverflowError + else: + error = ValueError + with pytest.raises(error): + xp.asarray_chkfinite(a, dtype=dtype, order=order) + + @testing.for_all_dtypes() + def test_asfarray(self, dtype): + a = cupy.asarray([1, 2, 3]) + a_gpu = cupy.asfarray(a, dtype) + a_cpu = numpy.asfarray(a, dtype) + assert a_cpu.dtype == a_gpu.dtype + + @testing.for_all_dtypes() + def test_asfortranarray1(self, dtype): + def func(xp): + x = xp.zeros((2, 3), dtype=dtype) + ret = xp.asfortranarray(x) + assert x.flags.c_contiguous + assert ret.flags.f_contiguous + + assert func(numpy) == func(cupy) + + @testing.for_all_dtypes() + def test_asfortranarray2(self, dtype): + def func(xp): + x = xp.zeros((2, 3, 4), dtype=dtype) + ret = xp.asfortranarray(x) + assert x.flags.c_contiguous + assert ret.flags.f_contiguous + + assert func(numpy) == func(cupy) + + @testing.for_all_dtypes() + def test_asfortranarray3(self, dtype): + def func(xp): + x = xp.zeros((2, 3, 4), dtype=dtype) + ret = xp.asfortranarray(xp.asfortranarray(x)) + assert x.flags.c_contiguous + assert ret.flags.f_contiguous + + assert func(numpy) == func(cupy) + + @testing.for_all_dtypes() + def test_asfortranarray4(self, dtype): + def func(xp): + x = xp.zeros((2, 3), dtype=dtype) + x = xp.transpose(x, (1, 0)) + ret = xp.asfortranarray(x) + assert ret.flags.f_contiguous + + assert func(numpy) == func(cupy) + + @testing.for_all_dtypes() + def test_asfortranarray5(self, dtype): + def func(xp): + x = testing.shaped_arange((2, 3), xp, dtype) + ret = xp.asfortranarray(x) + assert x.flags.c_contiguous + assert ret.flags.f_contiguous + + assert func(numpy) == func(cupy) + + @testing.for_all_dtypes() + def test_require_flag_check(self, dtype): + possible_flags = [["C_CONTIGUOUS"], ["F_CONTIGUOUS"]] + x = cupy.zeros((2, 3, 4), dtype=dtype) + for flags in possible_flags: + arr = cupy.require(x, dtype, flags) + for parameter in flags: + assert arr.flags[parameter] + assert arr.dtype == dtype + + @testing.for_all_dtypes() + def test_require_owndata(self, dtype): + x = cupy.zeros((2, 3, 4), dtype=dtype) + arr = x.view() + arr = cupy.require(arr, dtype, ["O"]) + assert arr.flags["OWNDATA"] + + @testing.for_all_dtypes() + def test_require_C_and_F_flags(self, dtype): + x = cupy.zeros((2, 3, 4), dtype=dtype) + with pytest.raises(ValueError): + cupy.require(x, dtype, ["C", "F"]) + + @testing.for_all_dtypes() + def test_require_incorrect_requirments(self, dtype): + x = cupy.zeros((2, 3, 4), dtype=dtype) + with pytest.raises(ValueError): + cupy.require(x, dtype, ["W"]) + + @testing.for_all_dtypes() + def test_require_incorrect_dtype(self, dtype): + x = cupy.zeros((2, 3, 4), dtype=dtype) + with pytest.raises(ValueError): + cupy.require(x, "random", "C") + + @testing.for_all_dtypes() + def test_require_empty_requirements(self, dtype): + x = cupy.zeros((2, 3, 4), dtype=dtype) + x = cupy.require(x, dtype, []) + assert x.flags["C_CONTIGUOUS"] From ce9375b384869aa1c004b2e319c21208cec2fc89 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Wed, 30 Aug 2023 11:11:32 -0500 Subject: [PATCH 3/6] Fixed example for asfarray function. --- dpnp/dpnp_iface_manipulation.py | 10 +++++----- tests/skipped_tests.tbl | 9 --------- tests/skipped_tests_gpu.tbl | 9 --------- tests/third_party/cupy/manipulation_tests/test_kind.py | 8 ++++++++ 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 4f794940218..8302a18a179 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -99,9 +99,9 @@ def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None): >>> import dpnp as np >>> np.asfarray([2, 3]) array([2., 3.]) - >>> np.asfarray([2, 3], dtype='float') - array([2., 3.]) - >>> np.asfarray([2, 3], dtype='int8') + >>> np.asfarray([2, 3], dtype='float16') + array([2., 3.], dtype=float16) + >>> np.asfarray([2, 3], dtype='int32') array([2., 3.]) """ @@ -113,8 +113,8 @@ def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None): if dtype is None or not numpy.issubdtype(dtype, dpnp.inexact): dtype = dpnp.default_float_type(sycl_queue=_sycl_queue) - return dpnp.array( - a, dtype=dtype, copy=False, usm_type=usm_type, sycl_queue=_sycl_queue + return dpnp.asarray( + a, dtype=dtype, usm_type=usm_type, sycl_queue=_sycl_queue ) diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index 70e2213620f..9c5b855f363 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -483,15 +483,6 @@ tests/third_party/cupy/manipulation_tests/test_shape.py::TestRavel::test_ravel tests/third_party/cupy/manipulation_tests/test_shape.py::TestReshape::test_reshape_zerosize tests/third_party/cupy/manipulation_tests/test_shape.py::TestReshape::test_reshape_zerosize2 -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite_non_finite_vals -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_C_and_F_flags -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_empty_requirements -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_flag_check -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_dtype -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_requirments -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_owndata - tests/third_party/cupy/manipulation_tests/test_tiling.py::TestRepeatRepeatsNdarray::test_func tests/third_party/cupy/manipulation_tests/test_tiling.py::TestRepeatRepeatsNdarray::test_method tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTileFailure_param_0_{reps=-1}::test_tile_failure diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index a88dbeae32c..f82c6107a4c 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -641,15 +641,6 @@ tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_3_{reps tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_4_{reps=(2, 3)}::test_array_tile tests/third_party/cupy/manipulation_tests/test_tiling.py::TestTile_param_5_{reps=(2, 3, 4, 5)}::test_array_tile -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_asarray_chkfinite_non_finite_vals -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_C_and_F_flags -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_empty_requirements -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_flag_check -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_dtype -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_incorrect_requirments -tests/third_party/cupy/manipulation_tests/test_kind.py::TestKind::test_require_owndata - tests/third_party/cupy/math_tests/test_arithmetic.py::TestArithmeticRaisesWithNumpyInput_param_3_{name='angle', nargs=1}::test_raises_with_numpy_input tests/third_party/cupy/math_tests/test_explog.py::TestExplog::test_logaddexp diff --git a/tests/third_party/cupy/manipulation_tests/test_kind.py b/tests/third_party/cupy/manipulation_tests/test_kind.py index 2d1ba7e5c64..e6efcd48b61 100644 --- a/tests/third_party/cupy/manipulation_tests/test_kind.py +++ b/tests/third_party/cupy/manipulation_tests/test_kind.py @@ -8,6 +8,7 @@ class TestKind(unittest.TestCase): + @pytest.mark.skip("dpnp.asarray_chkfinite() is not implemented yet") @testing.for_orders("CFAK") @testing.for_all_dtypes() @testing.numpy_cupy_array_equal() @@ -15,6 +16,7 @@ def test_asarray_chkfinite(self, xp, dtype, order): a = [0, 4, 0, 5] return xp.asarray_chkfinite(a, dtype=dtype, order=order) + @pytest.mark.skip("dpnp.asarray_chkfinite() is not implemented yet") @testing.for_orders("CFAK") @testing.for_all_dtypes(no_bool=True) def test_asarray_chkfinite_non_finite_vals(self, dtype, order): @@ -84,6 +86,7 @@ def func(xp): assert func(numpy) == func(cupy) + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_flag_check(self, dtype): possible_flags = [["C_CONTIGUOUS"], ["F_CONTIGUOUS"]] @@ -94,6 +97,7 @@ def test_require_flag_check(self, dtype): assert arr.flags[parameter] assert arr.dtype == dtype + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_owndata(self, dtype): x = cupy.zeros((2, 3, 4), dtype=dtype) @@ -101,24 +105,28 @@ def test_require_owndata(self, dtype): arr = cupy.require(arr, dtype, ["O"]) assert arr.flags["OWNDATA"] + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_C_and_F_flags(self, dtype): x = cupy.zeros((2, 3, 4), dtype=dtype) with pytest.raises(ValueError): cupy.require(x, dtype, ["C", "F"]) + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_incorrect_requirments(self, dtype): x = cupy.zeros((2, 3, 4), dtype=dtype) with pytest.raises(ValueError): cupy.require(x, dtype, ["W"]) + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_incorrect_dtype(self, dtype): x = cupy.zeros((2, 3, 4), dtype=dtype) with pytest.raises(ValueError): cupy.require(x, "random", "C") + @pytest.mark.skip("dpnp.require() is not implemented yet") @testing.for_all_dtypes() def test_require_empty_requirements(self, dtype): x = cupy.zeros((2, 3, 4), dtype=dtype) From 9949915e6a9d246cc9d3d9b71306c5c71395fadf Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Thu, 31 Aug 2023 10:41:12 -0700 Subject: [PATCH 4/6] Update dpnp/dpnp_iface_manipulation.py Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com> --- dpnp/dpnp_iface_manipulation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index 8302a18a179..b641cdbb4c9 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -99,9 +99,9 @@ def asfarray(a, dtype=None, *, device=None, usm_type=None, sycl_queue=None): >>> import dpnp as np >>> np.asfarray([2, 3]) array([2., 3.]) - >>> np.asfarray([2, 3], dtype='float16') - array([2., 3.], dtype=float16) - >>> np.asfarray([2, 3], dtype='int32') + >>> np.asfarray([2, 3], dtype=dpnp.float32) + array([2., 3.], dtype=float32) + >>> np.asfarray([2, 3], dtype=dpnp.int32) array([2., 3.]) """ From ca93f92a3e879009f5aecbfbc88f4ed8cffd58c7 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Tue, 5 Sep 2023 10:17:36 -0700 Subject: [PATCH 5/6] Update tests/third_party/cupy/manipulation_tests/test_kind.py Co-authored-by: Anton <100830759+antonwolfy@users.noreply.github.com> --- tests/third_party/cupy/manipulation_tests/test_kind.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/third_party/cupy/manipulation_tests/test_kind.py b/tests/third_party/cupy/manipulation_tests/test_kind.py index e6efcd48b61..8344423740c 100644 --- a/tests/third_party/cupy/manipulation_tests/test_kind.py +++ b/tests/third_party/cupy/manipulation_tests/test_kind.py @@ -34,7 +34,15 @@ def test_asfarray(self, dtype): a = cupy.asarray([1, 2, 3]) a_gpu = cupy.asfarray(a, dtype) a_cpu = numpy.asfarray(a, dtype) - assert a_cpu.dtype == a_gpu.dtype + if ( + has_support_aspect64() + or cupy.issubdtype(dtype, cupy.complexfloating) + or cupy.issubdtype(dtype, cupy.floating) + ): + assert a_cpu.dtype == a_gpu.dtype + else: + assert a_cpu.dtype == cupy.float64 + assert a_gpu.dtype == cupy.float32 @testing.for_all_dtypes() def test_asfortranarray1(self, dtype): From 3ca9530cc8972e13414dbb4befae67ed7f67b587 Mon Sep 17 00:00:00 2001 From: Natalia Polina Date: Wed, 6 Sep 2023 00:49:47 -0700 Subject: [PATCH 6/6] Update test_kind.py --- tests/third_party/cupy/manipulation_tests/test_kind.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/third_party/cupy/manipulation_tests/test_kind.py b/tests/third_party/cupy/manipulation_tests/test_kind.py index 8344423740c..1812d77c0af 100644 --- a/tests/third_party/cupy/manipulation_tests/test_kind.py +++ b/tests/third_party/cupy/manipulation_tests/test_kind.py @@ -4,6 +4,7 @@ import pytest import dpnp as cupy +from tests.helper import has_support_aspect64 from tests.third_party.cupy import testing