Skip to content

Commit dd8b737

Browse files
committed
Replace TODO comments in the source code with view() method where applicable
1 parent f88d6af commit dd8b737

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

dpnp/dpnp_utils/dpnp_utils_einsum.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,6 @@ def _transpose_ex(a, axeses):
945945
stride = sum(a.strides[axis] for axis in axes)
946946
strides.append(stride)
947947

948-
# TODO: replace with a.view() when it is implemented in dpnp
949948
return dpnp_array(
950949
shape,
951950
dtype=a.dtype,
@@ -1151,8 +1150,7 @@ def dpnp_einsum(
11511150
operands[idx] = operands[idx].sum(axis=sum_axes, dtype=result_dtype)
11521151

11531152
if returns_view:
1154-
# TODO: replace with a.view() when it is implemented in dpnp
1155-
operands = [a for a in operands]
1153+
operands = [a.view() for a in operands]
11561154
else:
11571155
operands = [
11581156
dpnp.astype(a, result_dtype, copy=False, casting=casting)

dpnp/linalg/dpnp_utils_linalg.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,8 @@ def _nrm2_last_axis(x):
12901290
"""
12911291

12921292
real_dtype = _real_type(x.dtype)
1293-
# TODO: use dpnp.sum(dpnp.square(dpnp.view(x)), axis=-1, dtype=real_dtype)
1294-
# w/a since dpnp.view() in not implemented yet
1295-
# Сalculate and sum the squares of both real and imaginary parts for
1296-
# compelex array.
1297-
if dpnp.issubdtype(x.dtype, dpnp.complexfloating):
1298-
y = dpnp.abs(x) ** 2
1299-
else:
1300-
y = dpnp.square(x)
1301-
return dpnp.sum(y, axis=-1, dtype=real_dtype)
1293+
x = dpnp.ascontiguousarray(x)
1294+
return dpnp.sum(dpnp.square(x.view(real_dtype)), axis=-1)
13021295

13031296

13041297
def _real_type(dtype, device=None):

0 commit comments

Comments
 (0)