Skip to content

Commit f840668

Browse files
authored
Merge branch 'master' into build_target_cuda
2 parents 8b8c4a3 + 808b976 commit f840668

File tree

15 files changed

+361
-83
lines changed

15 files changed

+361
-83
lines changed

.github/workflows/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @antonwolfy @npolina4 @vlad-perevezentsev @vtavana

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ repos:
9696
[
9797
"-rn", # Only display messages
9898
"-sn", # Don't display the score
99+
"--disable=c-extension-no-member",
99100
"--disable=import-error",
100101
"--disable=redefined-builtin",
101102
"--disable=unused-wildcard-import"

doc/reference/logic.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Comparison
6868
dpnp.allclose
6969
dpnp.isclose
7070
dpnp.array_equal
71+
dpnp.array_equiv
7172
dpnp.greater
7273
dpnp.greater_equal
7374
dpnp.less

dpnp/dpnp_array.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,31 +70,30 @@ def __init__(
7070
usm_type="device",
7171
sycl_queue=None,
7272
):
73+
if order is None:
74+
order = "C"
75+
7376
if buffer is not None:
74-
if not isinstance(buffer, dpt.usm_ndarray):
75-
raise TypeError(
76-
"Expected dpctl.tensor.usm_ndarray, got {}"
77-
"".format(type(buffer))
78-
)
79-
if buffer.shape != shape:
80-
raise ValueError(
81-
"Expected buffer.shape={}, got {}"
82-
"".format(shape, buffer.shape)
83-
)
84-
self._array_obj = dpt.asarray(buffer, copy=False, order=order)
77+
buffer = dpnp.get_usm_ndarray(buffer)
78+
79+
if dtype is None:
80+
dtype = buffer.dtype
8581
else:
86-
sycl_queue_normalized = dpnp.get_normalized_queue_device(
87-
device=device, sycl_queue=sycl_queue
88-
)
89-
self._array_obj = dpt.usm_ndarray(
90-
shape,
91-
dtype=dtype,
92-
strides=strides,
93-
buffer=usm_type,
94-
offset=offset,
95-
order=order,
96-
buffer_ctor_kwargs={"queue": sycl_queue_normalized},
97-
)
82+
buffer = usm_type
83+
84+
sycl_queue_normalized = dpnp.get_normalized_queue_device(
85+
device=device, sycl_queue=sycl_queue
86+
)
87+
88+
self._array_obj = dpt.usm_ndarray(
89+
shape,
90+
dtype=dtype,
91+
strides=strides,
92+
buffer=buffer,
93+
offset=offset,
94+
order=order,
95+
buffer_ctor_kwargs={"queue": sycl_queue_normalized},
96+
)
9897

9998
@property
10099
def __sycl_usm_array_interface__(self):
@@ -457,6 +456,8 @@ def __setitem__(self, key, val):
457456
# '__setstate__',
458457
# '__sizeof__',
459458

459+
__slots__ = ("_array_obj",)
460+
460461
def __str__(self):
461462
"""Return ``str(self)``."""
462463
return self._array_obj.__str__()
@@ -1275,6 +1276,9 @@ def shape(self, newshape):
12751276
12761277
"""
12771278

1279+
if not isinstance(newshape, (list, tuple)):
1280+
newshape = (newshape,)
1281+
12781282
self._array_obj.shape = newshape
12791283

12801284
@property

dpnp/dpnp_container.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def arange(
7979
usm_type=usm_type,
8080
sycl_queue=sycl_queue_normalized,
8181
)
82-
83-
return dpnp_array(array_obj.shape, buffer=array_obj)
82+
return dpnp_array._create_from_usm_ndarray(array_obj)
8483

8584

8685
def asarray(
@@ -132,7 +131,7 @@ def asarray(
132131
if array_obj is x1_obj and isinstance(x1, dpnp_array):
133132
return x1
134133

135-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
134+
return dpnp_array._create_from_usm_ndarray(array_obj)
136135

137136

138137
def copy(x1, /, *, order="K"):
@@ -141,7 +140,7 @@ def copy(x1, /, *, order="K"):
141140
order = "K"
142141

143142
array_obj = dpt.copy(dpnp.get_usm_ndarray(x1), order=order)
144-
return dpnp_array(array_obj.shape, buffer=array_obj, order="K")
143+
return dpnp_array._create_from_usm_ndarray(array_obj)
145144

146145

147146
def empty(
@@ -169,7 +168,7 @@ def empty(
169168
usm_type=usm_type,
170169
sycl_queue=sycl_queue_normalized,
171170
)
172-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
171+
return dpnp_array._create_from_usm_ndarray(array_obj)
173172

174173

175174
def eye(
@@ -202,7 +201,7 @@ def eye(
202201
usm_type=usm_type,
203202
sycl_queue=sycl_queue_normalized,
204203
)
205-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
204+
return dpnp_array._create_from_usm_ndarray(array_obj)
206205

207206

208207
def full(
@@ -236,7 +235,7 @@ def full(
236235
usm_type=usm_type,
237236
sycl_queue=sycl_queue_normalized,
238237
)
239-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
238+
return dpnp_array._create_from_usm_ndarray(array_obj)
240239

241240

242241
def ones(
@@ -264,19 +263,19 @@ def ones(
264263
usm_type=usm_type,
265264
sycl_queue=sycl_queue_normalized,
266265
)
267-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
266+
return dpnp_array._create_from_usm_ndarray(array_obj)
268267

269268

270269
def tril(x1, /, *, k=0):
271270
"""Creates `dpnp_array` as lower triangular part of an input array."""
272271
array_obj = dpt.tril(dpnp.get_usm_ndarray(x1), k=k)
273-
return dpnp_array(array_obj.shape, buffer=array_obj, order="K")
272+
return dpnp_array._create_from_usm_ndarray(array_obj)
274273

275274

276275
def triu(x1, /, *, k=0):
277276
"""Creates `dpnp_array` as upper triangular part of an input array."""
278277
array_obj = dpt.triu(dpnp.get_usm_ndarray(x1), k=k)
279-
return dpnp_array(array_obj.shape, buffer=array_obj, order="K")
278+
return dpnp_array._create_from_usm_ndarray(array_obj)
280279

281280

282281
def zeros(
@@ -304,4 +303,4 @@ def zeros(
304303
usm_type=usm_type,
305304
sycl_queue=sycl_queue_normalized,
306305
)
307-
return dpnp_array(array_obj.shape, buffer=array_obj, order=order)
306+
return dpnp_array._create_from_usm_ndarray(array_obj)

dpnp/dpnp_iface.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656

5757
__all__ = [
5858
"are_same_logical_tensors",
59-
"array_equal",
6059
"asnumpy",
6160
"astype",
6261
"as_usm_ndarray",
@@ -173,24 +172,6 @@ def are_same_logical_tensors(ar1, ar2):
173172
)
174173

175174

176-
def array_equal(a1, a2, equal_nan=False):
177-
"""
178-
True if two arrays have the same shape and elements, False otherwise.
179-
180-
For full documentation refer to :obj:`numpy.array_equal`.
181-
182-
See Also
183-
--------
184-
:obj:`dpnp.allclose` : Returns True if two arrays are element-wise equal
185-
within a tolerance.
186-
:obj:`dpnp.array_equiv` : Returns True if input arrays are shape consistent
187-
and all elements equal.
188-
189-
"""
190-
191-
return numpy.array_equal(a1, a2, equal_nan=equal_nan)
192-
193-
194175
def asnumpy(a, order="C"):
195176
"""
196177
Returns the NumPy array with input data.

dpnp/dpnp_iface_bitwise.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"""
3939

4040
# pylint: disable=protected-access
41-
# pylint: disable=c-extension-no-member
4241

4342

4443
import dpctl.tensor._tensor_elementwise_impl as ti

0 commit comments

Comments
 (0)