Skip to content

Commit 80dcf13

Browse files
committed
Add dpnp.ndarray.data property
1 parent 9b73305 commit 80dcf13

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

dpnp/dpnp_array.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from dpctl.tensor._numpy_helper import AxisError
3030

3131
import dpnp
32+
import dpnp.memory as dpm
3233

3334

3435
def _get_unwrapped_index_key(key):
@@ -76,9 +77,12 @@ def __init__(
7677
order = "C"
7778

7879
if buffer is not None:
79-
buffer = dpnp.get_usm_ndarray(buffer)
80+
# expecting to have buffer as dpnp.ndarray and usm_ndarray,
81+
# or as USM memory allocation
82+
if isinstance(buffer, dpnp_array):
83+
buffer = buffer.get_array()
8084

81-
if dtype is None:
85+
if dtype is None and hasattr(buffer, "dtype"):
8286
dtype = buffer.dtype
8387
else:
8488
buffer = usm_type
@@ -1015,7 +1019,15 @@ def cumsum(self, axis=None, dtype=None, out=None):
10151019

10161020
return dpnp.cumsum(self, axis=axis, dtype=dtype, out=out)
10171021

1018-
# 'data',
1022+
@property
1023+
def data(self):
1024+
"""
1025+
Python object pointing to the start of USM memory allocation with the
1026+
array's data.
1027+
1028+
"""
1029+
1030+
return dpm.create_data(self._array_obj)
10191031

10201032
def diagonal(self, offset=0, axis1=0, axis2=1):
10211033
"""

0 commit comments

Comments
 (0)