Skip to content

Commit

Permalink
Test order argument of UsmNDArray_MakeFromMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-pavlyk committed Feb 1, 2023
1 parent 12041a3 commit 5145923
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dpctl/tests/test_usm_ndarray_ctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,14 +532,15 @@ def test_pyx_capi_make_from_memory():
any_usm_ndarray,
"UsmNDArray_MakeFromMemory",
b"PyObject *(int, Py_ssize_t const *, int, "
b"struct Py_MemoryObject *, Py_ssize_t)",
b"struct Py_MemoryObject *, Py_ssize_t, char)",
fn_restype=ctypes.py_object,
fn_argtypes=(
ctypes.c_int,
ctypes.POINTER(ctypes.c_ssize_t),
ctypes.c_int,
ctypes.py_object,
ctypes.c_ssize_t,
ctypes.c_char,
),
)
r = make_from_memory_fn(
Expand All @@ -548,13 +549,31 @@ def test_pyx_capi_make_from_memory():
ctypes.c_int(typenum),
mem,
ctypes.c_ssize_t(0),
ctypes.c_char(b"C"),
)
assert isinstance(r, dpt.usm_ndarray)
assert r.ndim == 2
assert r.shape == (n0, n1)
assert r._pointer == mem._pointer
assert r.usm_type == "shared"
assert r.sycl_queue == q
assert r.flags["C"]
r2 = make_from_memory_fn(
ctypes.c_int(2),
c_tuple,
ctypes.c_int(typenum),
mem,
ctypes.c_ssize_t(0),
ctypes.c_char(b"F"),
)
ptr = mem._pointer
del mem
del r
assert isinstance(r2, dpt.usm_ndarray)
assert r2._pointer == ptr
assert r2.usm_type == "shared"
assert r2.sycl_queue == q
assert r2.flags["F"]


def test_pyx_capi_set_writable_flag():
Expand Down

0 comments on commit 5145923

Please sign in to comment.