Skip to content

Commit edf7990

Browse files
authored
Merge branch 'master' into drop_build_py_38
2 parents 2b1173b + 44fddf7 commit edf7990

13 files changed

+209
-283
lines changed

dpnp/dpnp_algo/dpnp_algo_manipulation.pxi

-45
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ and the rest of the library
3838
__all__ += [
3939
"dpnp_atleast_2d",
4040
"dpnp_atleast_3d",
41-
"dpnp_expand_dims",
4241
"dpnp_repeat",
43-
"dpnp_reshape",
4442
]
4543

4644

@@ -104,35 +102,6 @@ cpdef utils.dpnp_descriptor dpnp_atleast_3d(utils.dpnp_descriptor arr):
104102
return arr
105103

106104

107-
cpdef utils.dpnp_descriptor dpnp_expand_dims(utils.dpnp_descriptor in_array, axis):
108-
axis_tuple = utils._object_to_tuple(axis)
109-
result_ndim = len(axis_tuple) + in_array.ndim
110-
111-
if len(axis_tuple) == 0:
112-
axis_ndim = 0
113-
else:
114-
axis_ndim = max(-min(0, min(axis_tuple)), max(0, max(axis_tuple))) + 1
115-
116-
axis_norm = utils._object_to_tuple(utils.normalize_axis(axis_tuple, result_ndim))
117-
118-
if axis_ndim - len(axis_norm) > in_array.ndim:
119-
utils.checker_throw_axis_error("dpnp_expand_dims", "axis", axis, axis_ndim)
120-
121-
if len(axis_norm) > len(set(axis_norm)):
122-
utils.checker_throw_value_error("dpnp_expand_dims", "axis", axis, "no repeated axis")
123-
124-
cdef shape_type_c shape_list
125-
axis_idx = 0
126-
for i in range(result_ndim):
127-
if i in axis_norm:
128-
shape_list.push_back(1)
129-
else:
130-
shape_list.push_back(in_array.shape[axis_idx])
131-
axis_idx = axis_idx + 1
132-
133-
return dpnp_reshape(in_array, shape_list)
134-
135-
136105
cpdef utils.dpnp_descriptor dpnp_repeat(utils.dpnp_descriptor array1, repeats, axes=None):
137106
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(array1.dtype)
138107

@@ -165,17 +134,3 @@ cpdef utils.dpnp_descriptor dpnp_repeat(utils.dpnp_descriptor array1, repeats, a
165134
c_dpctl.DPCTLEvent_Delete(event_ref)
166135

167136
return result
168-
169-
170-
cpdef utils.dpnp_descriptor dpnp_reshape(utils.dpnp_descriptor array1, newshape, order="C"):
171-
# return dpnp.get_dpnp_descriptor(dpctl.tensor.usm_ndarray(newshape, dtype=numpy.dtype(array1.dtype).name, buffer=array1.get_pyobj()))
172-
# return dpnp.get_dpnp_descriptor(dpctl.tensor.reshape(array1.get_pyobj(), newshape))
173-
array1_obj = array1.get_array()
174-
array_obj = dpctl.tensor.reshape(array1_obj, newshape, order=order)
175-
return dpnp.get_dpnp_descriptor(dpnp_array(array_obj.shape,
176-
buffer=array_obj,
177-
order=order,
178-
device=array1_obj.sycl_device,
179-
usm_type=array1_obj.usm_type,
180-
sycl_queue=array1_obj.sycl_queue),
181-
copy_when_nondefault_queue=False)

dpnp/dpnp_algo/dpnp_elementwise_common.py

-23
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# *****************************************************************************
2828

2929

30-
import dpctl
31-
import dpctl.tensor as dpt
3230
import dpctl.tensor._tensor_impl as ti
3331
from dpctl.tensor._elementwise_common import (
3432
BinaryElementwiseFunc,
@@ -538,32 +536,11 @@ def _call_divide(src1, src2, dst, sycl_queue, depends=None):
538536
return ti._divide(src1, src2, dst, sycl_queue, depends)
539537

540538

541-
def _call_divide_inplace(lhs, rhs, sycl_queue, depends=None):
542-
"""In place workaround until dpctl.tensor provides the functionality."""
543-
544-
if depends is None:
545-
depends = []
546-
547-
# allocate temporary memory for out array
548-
out = dpt.empty_like(lhs, dtype=dpnp.result_type(lhs.dtype, rhs.dtype))
549-
550-
# call a general callback
551-
div_ht_, div_ev_ = _call_divide(lhs, rhs, out, sycl_queue, depends)
552-
553-
# store the result into left input array and return events
554-
cp_ht_, cp_ev_ = ti._copy_usm_ndarray_into_usm_ndarray(
555-
src=out, dst=lhs, sycl_queue=sycl_queue, depends=[div_ev_]
556-
)
557-
dpctl.SyclEvent.wait_for([div_ht_])
558-
return (cp_ht_, cp_ev_)
559-
560-
561539
divide_func = BinaryElementwiseFunc(
562540
"divide",
563541
ti._divide_result_type,
564542
_call_divide,
565543
_divide_docstring_,
566-
_call_divide_inplace,
567544
)
568545

569546

dpnp/dpnp_array.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ def __eq__(self, other):
188188
def __float__(self):
189189
return self._array_obj.__float__()
190190

191-
# '__floordiv__',
191+
def __floordiv__(self, other):
192+
"""Return self//value."""
193+
return dpnp.floor_divide(self, other)
194+
192195
# '__format__',
193196

194197
def __ge__(self, other):
@@ -227,15 +230,22 @@ def __iand__(self, other):
227230
dpnp.bitwise_and(self, other, out=self)
228231
return self
229232

230-
# '__ifloordiv__',
233+
def __ifloordiv__(self, other):
234+
"""Return self//=value."""
235+
dpnp.floor_divide(self, other, out=self)
236+
return self
231237

232238
def __ilshift__(self, other):
233239
"""Return self<<=value."""
234240
dpnp.left_shift(self, other, out=self)
235241
return self
236242

237243
# '__imatmul__',
238-
# '__imod__',
244+
245+
def __imod__(self, other):
246+
"""Return self%=value."""
247+
dpnp.remainder(self, other, out=self)
248+
return self
239249

240250
def __imul__(self, other):
241251
"""Return self*=value."""
@@ -345,7 +355,8 @@ def __rand__(self, other):
345355
def __repr__(self):
346356
return dpt.usm_ndarray_repr(self._array_obj, prefix="array")
347357

348-
# '__rfloordiv__',
358+
def __rfloordiv__(self, other):
359+
return dpnp.floor_divide(self, other)
349360

350361
def __rlshift__(self, other):
351362
return dpnp.left_shift(other, self)
@@ -1059,7 +1070,14 @@ def sum(
10591070
where=where,
10601071
)
10611072

1062-
# 'swapaxes',
1073+
def swapaxes(self, axis1, axis2):
1074+
"""
1075+
Interchange two axes of an array.
1076+
1077+
For full documentation refer to :obj:`numpy.swapaxes`.
1078+
"""
1079+
1080+
return dpnp.swapaxes(self, axis1=axis1, axis2=axis2)
10631081

10641082
def take(self, indices, /, *, axis=None, out=None, mode="wrap"):
10651083
"""

0 commit comments

Comments
 (0)