diff --git a/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi b/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi index 43b8310578d..4280bd621ce 100644 --- a/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi +++ b/dpnp/dpnp_algo/dpnp_algo_manipulation.pxi @@ -38,9 +38,7 @@ and the rest of the library __all__ += [ "dpnp_atleast_2d", "dpnp_atleast_3d", - "dpnp_expand_dims", "dpnp_repeat", - "dpnp_reshape", ] @@ -104,35 +102,6 @@ cpdef utils.dpnp_descriptor dpnp_atleast_3d(utils.dpnp_descriptor arr): return arr -cpdef utils.dpnp_descriptor dpnp_expand_dims(utils.dpnp_descriptor in_array, axis): - axis_tuple = utils._object_to_tuple(axis) - result_ndim = len(axis_tuple) + in_array.ndim - - if len(axis_tuple) == 0: - axis_ndim = 0 - else: - axis_ndim = max(-min(0, min(axis_tuple)), max(0, max(axis_tuple))) + 1 - - axis_norm = utils._object_to_tuple(utils.normalize_axis(axis_tuple, result_ndim)) - - if axis_ndim - len(axis_norm) > in_array.ndim: - utils.checker_throw_axis_error("dpnp_expand_dims", "axis", axis, axis_ndim) - - if len(axis_norm) > len(set(axis_norm)): - utils.checker_throw_value_error("dpnp_expand_dims", "axis", axis, "no repeated axis") - - cdef shape_type_c shape_list - axis_idx = 0 - for i in range(result_ndim): - if i in axis_norm: - shape_list.push_back(1) - else: - shape_list.push_back(in_array.shape[axis_idx]) - axis_idx = axis_idx + 1 - - return dpnp_reshape(in_array, shape_list) - - cpdef utils.dpnp_descriptor dpnp_repeat(utils.dpnp_descriptor array1, repeats, axes=None): cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype) @@ -165,17 +134,3 @@ cpdef utils.dpnp_descriptor dpnp_repeat(utils.dpnp_descriptor array1, repeats, a c_dpctl.DPCTLEvent_Delete(event_ref) return result - - -cpdef utils.dpnp_descriptor dpnp_reshape(utils.dpnp_descriptor array1, newshape, order="C"): - # return dpnp.get_dpnp_descriptor(dpctl.tensor.usm_ndarray(newshape, dtype=numpy.dtype(array1.dtype).name, buffer=array1.get_pyobj())) - # return dpnp.get_dpnp_descriptor(dpctl.tensor.reshape(array1.get_pyobj(), newshape)) - array1_obj = array1.get_array() - array_obj = dpctl.tensor.reshape(array1_obj, newshape, order=order) - return dpnp.get_dpnp_descriptor(dpnp_array(array_obj.shape, - buffer=array_obj, - order=order, - device=array1_obj.sycl_device, - usm_type=array1_obj.usm_type, - sycl_queue=array1_obj.sycl_queue), - copy_when_nondefault_queue=False) diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 717cb9c4f52..0c33e1a25c3 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -1059,7 +1059,14 @@ def sum( where=where, ) - # 'swapaxes', + def swapaxes(self, axis1, axis2): + """ + Interchange two axes of an array. + + For full documentation refer to :obj:`numpy.swapaxes`. + """ + + return dpnp.swapaxes(self, axis1=axis1, axis2=axis2) def take(self, indices, /, *, axis=None, out=None, mode="wrap"): """ diff --git a/dpnp/dpnp_iface_manipulation.py b/dpnp/dpnp_iface_manipulation.py index e29e6b0203e..a7ce7fb560e 100644 --- a/dpnp/dpnp_iface_manipulation.py +++ b/dpnp/dpnp_iface_manipulation.py @@ -75,7 +75,7 @@ ] -def asfarray(x1, dtype=None): +def asfarray(a, dtype=None): """ Return an array converted to a float type. @@ -89,18 +89,18 @@ def asfarray(x1, dtype=None): """ - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) - if x1_desc: + 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): - dtype = dpnp.default_float_type(sycl_queue=x1.sycl_queue) + dtype = dpnp.default_float_type(sycl_queue=a.sycl_queue) # if type is the same then same object should be returned - if x1_desc.dtype == dtype: - return x1 + if a_desc.dtype == dtype: + return a - return array(x1, dtype=dtype) + return array(a, dtype=dtype) - return call_origin(numpy.asfarray, x1, dtype) + return call_origin(numpy.asfarray, a, dtype) def atleast_1d(*arys): @@ -197,7 +197,7 @@ def atleast_3d(*arys): return call_origin(numpy.atleast_3d, *arys) -def broadcast_to(x, /, shape, subok=False): +def broadcast_to(array, /, shape, subok=False): """ Broadcast an array to a new shape. @@ -206,15 +206,15 @@ def broadcast_to(x, /, shape, subok=False): Returns ------- y : dpnp.ndarray - An array having a specified shape. Must have the same data type as `x`. + An array having a specified shape. Must have the same data type as `array`. Limitations ----------- - Parameter `x` is supported as either :class:`dpnp.ndarray` + Parameter `array` is supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`. Parameter `subok` is supported with default value. Otherwise the function will be executed sequentially on CPU. - Input array data types of `x` is limited by supported DPNP :ref:`Data types`. + Input array data types of `array` is limited by supported DPNP :ref:`Data types`. Examples -------- @@ -229,12 +229,12 @@ def broadcast_to(x, /, shape, subok=False): if subok is not False: pass - elif isinstance(x, dpnp_array) or isinstance(x, dpt.usm_ndarray): - dpt_array = x.get_array() if isinstance(x, dpnp_array) else x + elif dpnp.is_supported_array_type(array): + dpt_array = dpnp.get_usm_ndarray(array) new_array = dpt.broadcast_to(dpt_array, shape) return dpnp_array._create_from_usm_ndarray(new_array) - return call_origin(numpy.broadcast_to, x, shape=shape, subok=subok) + return call_origin(numpy.broadcast_to, array, shape=shape, subok=subok) def concatenate(arrays, /, *, axis=0, out=None, dtype=None, **kwargs): @@ -388,7 +388,7 @@ def copyto(dst, src, casting="same_kind", where=True): dst_usm[mask_usm] = src_usm[mask_usm] -def expand_dims(x1, axis): +def expand_dims(a, axis): """ Expand the shape of an array. @@ -397,11 +397,35 @@ def expand_dims(x1, axis): For full documentation refer to :obj:`numpy.expand_dims`. + Returns + ------- + dpnp.ndarray + An array with the number of dimensions increased. + A view is returned whenever possible. + + Limitations + ----------- + Parameters `a` is supported either as :class:`dpnp.ndarray` + or :class:`dpctl.tensor.usm_ndarray`. + Input array data types are limited by supported DPNP :ref:`Data types`. + Otherwise ``TypeError`` exception will be raised. + + Notes + ----- + If `a` has rank (i.e, number of dimensions) `N`, a valid `axis` must reside + in the closed-interval `[-N-1, N]`. + If provided a negative `axis`, the `axis` position at which to insert a + singleton dimension is computed as `N + axis + 1`. + Hence, if provided `-1`, the resolved axis position is `N` (i.e., + a singleton dimension must be appended to the input array `a`). + If provided `-N-1`, the resolved axis position is `0` (i.e., a + singleton dimension is prepended to the input array `a`). + See Also -------- :obj:`dpnp.squeeze` : The inverse operation, removing singleton dimensions :obj:`dpnp.reshape` : Insert, remove, and combine dimensions, and resize existing ones - :obj:`dpnp.indexing`, :obj:`dpnp.atleast_1d`, :obj:`dpnp.atleast_2d`, :obj:`dpnp.atleast_3d` + :obj:`dpnp.atleast_1d`, :obj:`dpnp.atleast_2d`, :obj:`dpnp.atleast_3d` Examples -------- @@ -446,11 +470,10 @@ def expand_dims(x1, axis): """ - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) - if x1_desc: - return dpnp_expand_dims(x1_desc, axis).get_pyobj() - - return call_origin(numpy.expand_dims, x1, axis) + dpt_array = dpnp.get_usm_ndarray(a) + return dpnp_array._create_from_usm_ndarray( + dpt.expand_dims(dpt_array, axis=axis) + ) def hstack(tup): @@ -472,7 +495,7 @@ def hstack(tup): return call_origin(numpy.hstack, tup_new) -def moveaxis(x, source, destination): +def moveaxis(a, source, destination): """ Move axes of an array to new positions. Other axes remain in their original order. @@ -483,14 +506,14 @@ def moveaxis(x, source, destination): out : dpnp.ndarray Array with moved axes. The returned array will have the same data and - the same USM allocation type as `x`. + the same USM allocation type as `a`. Limitations ----------- - Parameters `x` is supported as either :class:`dpnp.ndarray` + Parameters `a` is supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`. - Otherwise the function will be executed sequentially on CPU. Input array data types are limited by supported DPNP :ref:`Data types`. + Otherwise ``TypeError`` exception will be raised. See Also -------- @@ -508,16 +531,13 @@ def moveaxis(x, source, destination): """ - if isinstance(x, dpnp_array) or isinstance(x, dpt.usm_ndarray): - dpt_array = x.get_array() if isinstance(x, dpnp_array) else x - return dpnp_array._create_from_usm_ndarray( - dpt.moveaxis(dpt_array, source, destination) - ) - - return call_origin(numpy.moveaxis, x, source, destination) + dpt_array = dpnp.get_usm_ndarray(a) + return dpnp_array._create_from_usm_ndarray( + dpt.moveaxis(dpt_array, source, destination) + ) -def ravel(x1, order="C"): +def ravel(a, order="C"): """ Return a contiguous flattened array. @@ -539,14 +559,14 @@ def ravel(x1, order="C"): """ - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) - if x1_desc: - return dpnp_flatten(x1_desc).get_pyobj() + a_desc = dpnp.get_dpnp_descriptor(a, copy_when_nondefault_queue=False) + if a_desc: + return dpnp_flatten(a_desc).get_pyobj() - return call_origin(numpy.ravel, x1, order=order) + return call_origin(numpy.ravel, a, order=order) -def repeat(x1, repeats, axis=None): +def repeat(a, repeats, axis=None): """ Repeat elements of an array. @@ -572,22 +592,22 @@ def repeat(x1, repeats, axis=None): """ - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) - if x1_desc: + a_desc = dpnp.get_dpnp_descriptor(a, copy_when_nondefault_queue=False) + if a_desc: if axis is not None and axis != 0: pass - elif x1_desc.ndim >= 2: + elif a_desc.ndim >= 2: pass elif not dpnp.isscalar(repeats) and len(repeats) > 1: pass else: repeat_val = repeats if dpnp.isscalar(repeats) else repeats[0] - return dpnp_repeat(x1_desc, repeat_val, axis).get_pyobj() + return dpnp_repeat(a_desc, repeat_val, axis).get_pyobj() - return call_origin(numpy.repeat, x1, repeats, axis) + return call_origin(numpy.repeat, a, repeats, axis) -def reshape(x, /, newshape, order="C", copy=None): +def reshape(a, /, newshape, order="C", copy=None): """ Gives a new shape to an array without changing its data. @@ -595,7 +615,7 @@ def reshape(x, /, newshape, order="C", copy=None): Parameters ---------- - x : {dpnp_array, usm_ndarray} + a : {dpnp_array, usm_ndarray} Array to be reshaped. newshape : int or tuple of ints The new shape should be compatible with the original shape. If @@ -603,7 +623,7 @@ def reshape(x, /, newshape, order="C", copy=None): One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions. order : {'C', 'F'}, optional - Read the elements of `x` using this index order, and place the + Read the elements of `a` using this index order, and place the elements into the reshaped array using this index order. 'C' means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first @@ -614,10 +634,10 @@ def reshape(x, /, newshape, order="C", copy=None): the underlying array, and only refer to the order of indexing. copy : bool, optional Boolean indicating whether or not to copy the input array. - If ``True``, the result array will always be a copy of input `x`. + If ``True``, the result array will always be a copy of input `a`. If ``False``, the result array can never be a copy and a ValueError exception will be raised in case the copy is necessary. - If ``None``, the result array will reuse existing memory buffer of `x` + If ``None``, the result array will reuse existing memory buffer of `a` if possible and copy otherwise. Default: None. Returns @@ -652,14 +672,14 @@ def reshape(x, /, newshape, order="C", copy=None): """ if newshape is None: - newshape = x.shape + newshape = a.shape if order is None: order = "C" elif order not in "cfCF": raise ValueError(f"order must be one of 'C' or 'F' (got {order})") - usm_arr = dpnp.get_usm_ndarray(x) + usm_arr = dpnp.get_usm_ndarray(a) usm_arr = dpt.reshape(usm_arr, shape=newshape, order=order, copy=copy) return dpnp_array._create_from_usm_ndarray(usm_arr) @@ -800,9 +820,9 @@ def shape(a): return numpy.shape(a) -def squeeze(x, /, axis=None): +def squeeze(a, /, axis=None): """ - Removes singleton dimensions (axes) from array `x`. + Removes singleton dimensions (axes) from array `a`. For full documentation refer to :obj:`numpy.squeeze`. @@ -814,13 +834,14 @@ def squeeze(x, /, axis=None): dimensions of length 1 removed. Output has the same data type as the input, is allocated on the same device as the input and has the same USM allocation type as the input - array `x`. + array `a`. Limitations ----------- - Parameters `x` is supported as either :class:`dpnp.ndarray` + Parameters `a` is supported as either :class:`dpnp.ndarray` or :class:`dpctl.tensor.usm_ndarray`. - Otherwise the function will be executed sequentially on CPU. + Input array data types are limited by supported DPNP :ref:`Data types`. + Otherwise ``TypeError`` exception will be raised. Examples -------- @@ -841,11 +862,10 @@ def squeeze(x, /, axis=None): """ - if isinstance(x, dpnp_array) or isinstance(x, dpt.usm_ndarray): - dpt_array = x.get_array() if isinstance(x, dpnp_array) else x - return dpnp_array._create_from_usm_ndarray(dpt.squeeze(dpt_array, axis)) - - return call_origin(numpy.squeeze, x, axis) + dpt_array = dpnp.get_usm_ndarray(a) + return dpnp_array._create_from_usm_ndarray( + dpt.squeeze(dpt_array, axis=axis) + ) def stack(arrays, /, *, axis=0, out=None, dtype=None, **kwargs): @@ -921,50 +941,57 @@ def stack(arrays, /, *, axis=0, out=None, dtype=None, **kwargs): ) -def swapaxes(x1, axis1, axis2): +def swapaxes(a, axis1, axis2): """ Interchange two axes of an array. For full documentation refer to :obj:`numpy.swapaxes`. + Returns + ------- + dpnp.ndarray + An array with with swapped axes. + A view is returned whenever possible. + Limitations ----------- - Input array is supported as :obj:`dpnp.ndarray`. - Otherwise the function will be executed sequentially on CPU. - Parameter ``axis1`` is limited by ``axis1 < x1.ndim``. - Parameter ``axis2`` is limited by ``axis2 < x1.ndim``. + Parameters `a` is supported either as :class:`dpnp.ndarray` + or :class:`dpctl.tensor.usm_ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. + Otherwise ``TypeError`` exception will be raised. + + Notes + ----- + If `a` has rank (i.e., number of dimensions) `N`, + a valid `axis` must be in the half-open interval `[-N, N)`. Examples -------- >>> import dpnp as np >>> x = np.array([[1, 2, 3]]) - >>> out = np.swapaxes(x, 0, 1) - >>> out.shape - (3, 1) - >>> [i for i in out] - [1, 2, 3] + >>> np.swapaxes(x, 0, 1) + array([[1], + [2], + [3]]) + + >>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]]) + >>> x + array([[[0, 1], + [2, 3]], + [[4, 5], + [6, 7]]]) + >>> np.swapaxes(x,0,2) + array([[[0, 4], + [2, 6]], + [[1, 5], + [3, 7]]]) """ - x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False) - if x1_desc: - if axis1 >= x1_desc.ndim: - pass - elif axis2 >= x1_desc.ndim: - pass - else: - # 'do nothing' pattern for transpose() - input_permute = [i for i in range(x1.ndim)] - # swap axes - input_permute[axis1], input_permute[axis2] = ( - input_permute[axis2], - input_permute[axis1], - ) - - return transpose(x1_desc.get_pyobj(), axes=input_permute) - - return call_origin(numpy.swapaxes, x1, axis1, axis2) + dpt_array = dpnp.get_usm_ndarray(a) + return dpnp_array._create_from_usm_ndarray( + dpt.swapaxes(dpt_array, axis1=axis1, axis2=axis2) + ) def transpose(a, axes=None): @@ -1030,7 +1057,7 @@ def transpose(a, axes=None): return array.transpose(*axes) -def unique(x1, **kwargs): +def unique(ar, **kwargs): """ Find the unique elements of an array. @@ -1046,7 +1073,7 @@ def unique(x1, **kwargs): """ - return call_origin(numpy.unique, x1, **kwargs) + return call_origin(numpy.unique, ar, **kwargs) def vstack(tup): diff --git a/tests/skipped_tests.tbl b/tests/skipped_tests.tbl index a78de781e3b..c7627f9c9d0 100644 --- a/tests/skipped_tests.tbl +++ b/tests/skipped_tests.tbl @@ -201,61 +201,17 @@ tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_pa tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_param_7_{order='F', shape=(10, 20, 30, 40)}::test_cub_max tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_param_7_{order='F', shape=(10, 20, 30, 40)}::test_cub_min tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity2 tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity3_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_huge_size tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_huge_size_fill0 tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_int_huge_size tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_int_huge_size_fill0 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_contiguity3 tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_invalid_order tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_K_strides tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_subok diff --git a/tests/skipped_tests_gpu.tbl b/tests/skipped_tests_gpu.tbl index 0b95dde9bb5..5bada1df5c8 100644 --- a/tests/skipped_tests_gpu.tbl +++ b/tests/skipped_tests_gpu.tbl @@ -329,61 +329,14 @@ tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_pa tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_param_7_{order='F', shape=(10, 20, 30, 40)}::test_cub_max tests/third_party/cupy/core_tests/test_ndarray_reduction.py::TestCubReduction_param_7_{order='F', shape=(10, 20, 30, 40)}::test_cub_min tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_0_{shape=4}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_1_{shape=(4,)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_2_{shape=(4, 2)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_3_{shape=(4, 2, 3)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_K_strides_reshape -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity2_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity3 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity3_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_contiguity_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_empty_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_full_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_ones_like_reshape_cupy_only -tests/third_party/cupy/creation_tests/test_basic.py::TestBasicReshape_param_4_{shape=(5, 4, 2, 3)}::test_zeros_like_reshape_cupy_only tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_huge_size tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_huge_size_fill0 tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_int_huge_size tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_int_huge_size_fill0 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_contiguity2 -tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_contiguity3 tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_invalid_order tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_K_strides tests/third_party/cupy/creation_tests/test_basic.py::TestBasic::test_empty_like_subok diff --git a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py index b5a73c25e95..2345a1be0d3 100644 --- a/tests/third_party/cupy/linalg_tests/test_eigenvalue.py +++ b/tests/third_party/cupy/linalg_tests/test_eigenvalue.py @@ -8,18 +8,14 @@ def _get_hermitian(xp, a, UPLO): - # TODO: remove wrapping, but now there is no dpnp_array.swapaxes() - a = _wrap_as_numpy_array(xp, a) - _xp = numpy - if UPLO == "U": - _a = _xp.triu(a) + _xp.triu(a, k=1).swapaxes(-2, -1).conj() + return xp.triu(a) + xp.triu(a, k=1).swapaxes(-2, -1).conj() else: - _a = _xp.tril(a) + _xp.tril(a, k=-1).swapaxes(-2, -1).conj() - return xp.array(_a) + return xp.tril(a) + xp.tril(a, k=-1).swapaxes(-2, -1).conj() -# TODO: remove once all required functionality is supported +# TODO: +# remove once dpnp.dot and dpnp.matmul support complex types def _wrap_as_numpy_array(xp, a): return a.asnumpy() if xp is cupy else a diff --git a/tests/third_party/cupy/manipulation_tests/test_basic.py b/tests/third_party/cupy/manipulation_tests/test_basic.py index 0712f88a736..46c3533a74f 100644 --- a/tests/third_party/cupy/manipulation_tests/test_basic.py +++ b/tests/third_party/cupy/manipulation_tests/test_basic.py @@ -120,10 +120,7 @@ def test_copyto_where_multidevice_raises(self, dtype): @testing.for_all_dtypes() def test_copyto_noncontinguous(self, dtype): src = testing.shaped_arange((2, 3, 4), cupy, dtype) - # TODO: replace with - # src = src.swapaxes(0, 1) - # once dpnp.ndarray.swapaxes() is fully implemented - src = cupy.swapaxes(src, 0, 1) + src = src.swapaxes(0, 1) dst = cupy.empty_like(src) cupy.copyto(dst, src) diff --git a/tests/third_party/cupy/manipulation_tests/test_transpose.py b/tests/third_party/cupy/manipulation_tests/test_transpose.py index ad71ad41b4b..07cbf4eb31c 100644 --- a/tests/third_party/cupy/manipulation_tests/test_transpose.py +++ b/tests/third_party/cupy/manipulation_tests/test_transpose.py @@ -115,7 +115,6 @@ def test_swapaxes(self, xp): a = testing.shaped_arange((2, 3, 4), xp) return xp.swapaxes(a, 2, 0) - @pytest.mark.usefixtures("allow_fall_back_on_numpy") def test_swapaxes_failure(self): for xp in (numpy, cupy): a = testing.shaped_arange((2, 3, 4), xp)