Skip to content

Commit 2829cb7

Browse files
If shape is same as in array, reshape is a no-op
Closes gh-1664 If copy is not required, and requested shape is the same as the shape of the array, return the array itself.
1 parent b8336de commit 2829cb7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

dpctl/tensor/_reshape.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ def reshape(X, /, shape, *, order="C", copy=None):
177177
tuple(shape), dtype=X.dtype, buffer=flat_res, order=order
178178
)
179179
# can form a view
180+
if (len(shape) == X.ndim) and all(
181+
s1 == s2 for s1, s2 in zip(shape, X.shape)
182+
):
183+
return X
180184
return dpt.usm_ndarray(
181185
shape,
182186
dtype=X.dtype,

0 commit comments

Comments
 (0)