Skip to content

Commit 62393db

Browse files
authored
Merge 5a92b88 into 4e02172
2 parents 4e02172 + 5a92b88 commit 62393db

File tree

77 files changed

+9195
-1807
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+9195
-1807
lines changed

dpnp/dpnp_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def mT(self):
150150
if self.ndim < 2:
151151
raise ValueError("matrix transpose with ndim < 2 is undefined")
152152

153-
return self._array_obj.mT
153+
return dpnp_array._create_from_usm_ndarray(self._array_obj.mT)
154154

155155
def to_device(self, target_device):
156156
"""Transfer array to target device."""

dpnp/random/dpnp_iface_random.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,25 +1022,31 @@ def power(a, size=None):
10221022
return call_origin(numpy.random.power, a, size)
10231023

10241024

1025-
def rand(d0, *dn, device=None, usm_type="device", sycl_queue=None):
1025+
def rand(*args, device=None, usm_type="device", sycl_queue=None):
10261026
"""
10271027
Random values in a given shape.
10281028
1029-
Create an array of the given shape and populate it with random samples
1030-
from a uniform distribution over [0, 1).
1029+
Create an array of the given shape and populate it with random samples from
1030+
a uniform distribution over ``[0, 1)``.
10311031
10321032
For full documentation refer to :obj:`numpy.random.rand`.
10331033
10341034
Parameters
10351035
----------
1036+
d0, d1, ..., dn : int, optional
1037+
The dimensions of the returned array, must be non-negative.
1038+
If no argument is given a single Python float is returned.
10361039
device : {None, string, SyclDevice, SyclQueue}, optional
10371040
An array API concept of device where the output array is created.
1038-
The `device` can be ``None`` (the default), an OneAPI filter selector string,
1039-
an instance of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL device,
1040-
an instance of :class:`dpctl.SyclQueue`, or a `Device` object returned by
1041+
The `device` can be ``None`` (the default), an OneAPI filter selector
1042+
string, an instance of :class:`dpctl.SyclDevice` corresponding to
1043+
a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
1044+
or a `Device` object returned by
10411045
:obj:`dpnp.dpnp_array.dpnp_array.device` property.
1046+
Default: ``None``.
10421047
usm_type : {"device", "shared", "host"}, optional
10431048
The type of SYCL USM allocation for the output array.
1049+
Default: ``"device"``.
10441050
sycl_queue : {None, SyclQueue}, optional
10451051
A SYCL queue to use for output array allocation and copying. The
10461052
`sycl_queue` can be passed as ``None`` (the default), which means
@@ -1051,23 +1057,27 @@ def rand(d0, *dn, device=None, usm_type="device", sycl_queue=None):
10511057
Returns
10521058
-------
10531059
out : dpnp.ndarray
1054-
Random values in a given shape.
1055-
Output array data type is :obj:`dpnp.float64` if device supports it, or :obj:`dpnp.float32` otherwise.
1060+
Random values in a given shape ``(d0, d1, ..., dn)``.
1061+
Output array data type is :obj:`dpnp.float64` if a device supports it,
1062+
or :obj:`dpnp.float32` type otherwise.
10561063
1057-
Examples
1064+
See Also
10581065
--------
1059-
>>> s = dpnp.random.rand(3, 2)
1066+
:obj:`dpnp.random.random` : Return random floats in the half-open interval
1067+
``[0.0, 1.0)``.
1068+
:obj:`dpnp.random.random_sample` : Return random floats in the half-open
1069+
interval ``[0.0, 1.0)``.
1070+
:obj:`dpnp.random.uniform` : Draw samples from a uniform distribution.
10601071
1061-
See Also
1072+
Examples
10621073
--------
1063-
:obj:`dpnp.random.random`
1064-
:obj:`dpnp.random.random_sample`
1065-
:obj:`dpnp.random.uniform`
1074+
>>> import dpnp as np
1075+
>>> s = np.random.rand(3, 2)
10661076
10671077
"""
10681078

10691079
rs = _get_random_state(device=device, sycl_queue=sycl_queue)
1070-
return rs.rand(d0, *dn, usm_type=usm_type)
1080+
return rs.rand(*args, usm_type=usm_type)
10711081

10721082

10731083
def randint(

dpnp/tests/skipped_tests.tbl

Lines changed: 0 additions & 303 deletions
Large diffs are not rendered by default.

dpnp/tests/skipped_tests_gpu.tbl

Lines changed: 0 additions & 304 deletions
Large diffs are not rendered by default.

dpnp/tests/skipped_tests_gpu_no_fp64.tbl

Lines changed: 0 additions & 171 deletions
Large diffs are not rendered by default.

dpnp/tests/test_sycl_queue.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,24 +1078,27 @@ def test_vecdot(device, shape_pair):
10781078

10791079

10801080
@pytest.mark.parametrize(
1081-
"func, kwargs",
1081+
"func, args, kwargs",
10821082
[
1083-
pytest.param("normal", {"loc": 1.0, "scale": 3.4, "size": (5, 12)}),
1084-
pytest.param("rand", {"d0": 20}),
1083+
pytest.param("normal", [], {"loc": 1.0, "scale": 3.4, "size": (5, 12)}),
1084+
pytest.param("rand", [20], {}),
10851085
pytest.param(
10861086
"randint",
1087+
[],
10871088
{"low": 2, "high": 15, "size": (4, 8, 16), "dtype": dpnp.int32},
10881089
),
1089-
pytest.param("randn", {"d0": 20}),
1090-
pytest.param("random", {"size": (35, 45)}),
1090+
pytest.param("randn", [], {"d0": 20}),
1091+
pytest.param("random", [], {"size": (35, 45)}),
1092+
pytest.param(
1093+
"random_integers", [], {"low": -17, "high": 3, "size": (12, 16)}
1094+
),
1095+
pytest.param("random_sample", [], {"size": (7, 7)}),
1096+
pytest.param("ranf", [], {"size": (10, 7, 12)}),
1097+
pytest.param("sample", [], {"size": (7, 9)}),
1098+
pytest.param("standard_normal", [], {"size": (4, 4, 8)}),
10911099
pytest.param(
1092-
"random_integers", {"low": -17, "high": 3, "size": (12, 16)}
1100+
"uniform", [], {"low": 1.0, "high": 2.0, "size": (4, 2, 5)}
10931101
),
1094-
pytest.param("random_sample", {"size": (7, 7)}),
1095-
pytest.param("ranf", {"size": (10, 7, 12)}),
1096-
pytest.param("sample", {"size": (7, 9)}),
1097-
pytest.param("standard_normal", {"size": (4, 4, 8)}),
1098-
pytest.param("uniform", {"low": 1.0, "high": 2.0, "size": (4, 2, 5)}),
10991102
],
11001103
)
11011104
@pytest.mark.parametrize(
@@ -1104,11 +1107,11 @@ def test_vecdot(device, shape_pair):
11041107
ids=[device.filter_string for device in valid_devices],
11051108
)
11061109
@pytest.mark.parametrize("usm_type", ["host", "device", "shared"])
1107-
def test_random(func, kwargs, device, usm_type):
1110+
def test_random(func, args, kwargs, device, usm_type):
11081111
kwargs = {**kwargs, "device": device, "usm_type": usm_type}
11091112

11101113
# test with default SYCL queue per a device
1111-
res_array = getattr(dpnp.random, func)(**kwargs)
1114+
res_array = getattr(dpnp.random, func)(*args, **kwargs)
11121115
assert device == res_array.sycl_device
11131116
assert usm_type == res_array.usm_type
11141117

@@ -1120,7 +1123,7 @@ def test_random(func, kwargs, device, usm_type):
11201123
kwargs["sycl_queue"] = sycl_queue
11211124

11221125
# test with in-order SYCL queue per a device and passed as argument
1123-
res_array = getattr(dpnp.random, func)(**kwargs)
1126+
res_array = getattr(dpnp.random, func)(*args, **kwargs)
11241127
assert usm_type == res_array.usm_type
11251128
assert_sycl_queue_equal(res_array.sycl_queue, sycl_queue)
11261129

0 commit comments

Comments
 (0)