Skip to content

Commit 766cd5b

Browse files
Added a test to check MemoryConstructor(other_memory_object)
1 parent c700d83 commit 766cd5b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

dpctl/tests/test_sycl_usm.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,24 @@ def test_cpython_api(memory_ctor):
454454
capi_nbytes = get_nby_fn(mobj)
455455
direct_nbytes = mobj.nbytes
456456
assert capi_nbytes == direct_nbytes
457+
458+
459+
def test_memory_construction_from_other_memory_objects():
460+
try:
461+
q = dpctl.SyclQueue()
462+
except dpctl.SyclQueueCreationError:
463+
pytest.skip("Default queue could not be created")
464+
m_sh = MemoryUSMShared(256, queue=q)
465+
m_de = MemoryUSMDevice(256, queue=q)
466+
m_ho = MemoryUSMHost(256, queue=q)
467+
with pytest.raises(ValueError):
468+
MemoryUSMDevice(m_sh)
469+
with pytest.raises(ValueError):
470+
MemoryUSMHost(m_de)
471+
with pytest.raises(ValueError):
472+
MemoryUSMShared(m_ho)
473+
m1 = MemoryUSMDevice(m_sh, copy=True)
474+
m2 = MemoryUSMHost(m_de, copy=True)
475+
m3 = MemoryUSMShared(m_de, copy=True)
476+
assert bytes(m1) == bytes(m_sh)
477+
assert bytes(m2) == bytes(m3)

0 commit comments

Comments
 (0)