diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c45c670ba8..fbbd3323993f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Updated the math formulas in summary of `dpnp.matvec` and `dpnp.vecmat` to correct a typo [#2503](https://github.com/IntelPython/dpnp/pull/2503) * Avoided negating unsigned integers in ceil division used in `dpnp.resize` implementation [#2508](https://github.com/IntelPython/dpnp/pull/2508) * Fixed `dpnp.unique` with 1d input array and `axis=0`, `equal_nan=True` keywords passed where the produced result doesn't collapse the NaNs [#2530](https://github.com/IntelPython/dpnp/pull/2530) +* Resolved issue when `dpnp.ndarray` constructor is called with `dpnp.ndarray.data` as `buffer` keyword [#2533](https://github.com/IntelPython/dpnp/pull/2533) ### Security diff --git a/dpnp/memory/_memory.py b/dpnp/memory/_memory.py index c1f60ec14cc4..c3f0984c52e7 100644 --- a/dpnp/memory/_memory.py +++ b/dpnp/memory/_memory.py @@ -95,6 +95,9 @@ def create_data(x): ) usm_data = x.usm_data + if isinstance(usm_data, tuple(dispatch.values())): + return usm_data + cls = dispatch.get(type(usm_data), None) if cls: data = cls(usm_data) diff --git a/dpnp/tests/test_memory.py b/dpnp/tests/test_memory.py index 30afe5fa908c..ce9c7e60f030 100644 --- a/dpnp/tests/test_memory.py +++ b/dpnp/tests/test_memory.py @@ -26,3 +26,8 @@ def test_wrong_usm_data(self): with pytest.raises(TypeError): dpm.create_data(d) + + def test_ndarray_from_data(self): + a = dpnp.empty(5) + b = dpnp.ndarray(a.shape, buffer=a.data) + assert b.data.ptr == a.data.ptr