8000 Add GPU tests for DLPack support by leofang · Pull Request #59 · mpi4py/mpi4py · GitHub
[go: up one dir, main page]

Skip to content

Add GPU tests for DLPack support #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename DLPackBuf to DLPackCPUBuf for clarity
  • Loading branch information
leofang committed Jul 1, 2021
commit 79f64d5bcc54b288668c3dd1f31f446bb982974d
24 changes: 12 additions & 12 deletions test/test_msgspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def __setitem__(self, item, value):
except ImportError:
dlpack = None

class DLPackBuf(BaseBuf):
class DLPackCPUBuf(BaseBuf):

def __init__(self, typecode, initializer):
super(DLPackBuf, self).__init__(typecode, initializer)
super(DLPackCPUBuf, self).__init__(typecode, initializer)
self.managed = dlpack.make_dl_managed_tensor(self._buf)

def __del__(self):
Expand Down Expand Up @@ -425,11 +425,11 @@ def testNotContiguous(self):

@unittest.skipIf(array is None, 'array')
@unittest.skipIf(dlpack is None, 'dlpack')
class TestMessageSimpleDLPackBuf(unittest.TestCase,
class TestMessageSimpleDLPackCPUBuf(unittest.TestCase,
BaseTestMessageSimpleArray):

def array(self, typecode, initializer):
return DLPackBuf(typecode, initializer)
return DLPackCPUBuf(typecode, initializer)


@unittest.skipIf(array is None, 'array')
Expand Down Expand Up @@ -518,10 +518,10 @@ def testNotContiguous(self):

@unittest.skipIf(array is None, 'array')
@unittest.skipIf(dlpack is None, 'dlpack')
class TestMessageDLPackBuf(unittest.TestCase):
class TestMessageDLPackCPUBuf(unittest.TestCase):

def testDevice(self):
buf = DLPackBuf('i', [0,1,2,3])
buf = DLPackCPUBuf('i', [0,1,2,3])
buf.__dlpack_device__ = None
self.assertRaises(TypeError, MPI.Get_address, buf)
buf.__dlpack_device__ = lambda: None
Expand All @@ -538,7 +538,7 @@ def testDevice(self):
MPI.Get_address(buf)

def testCapsule(self):
buf = DLPackBuf('i', [0,1,2,3])
buf = DLPackCPUBuf('i', [0,1,2,3])
#
capsule = buf.__dlpack__()
MPI.Get_address(buf)
Expand All @@ -558,7 +558,7 @@ def testCapsule(self):
del buf.__dlpack__

def testNdim(self):
buf = DLPackBuf('i', [0,1,2,3])
buf = DLPackCPUBuf('i', [0,1,2,3])
dltensor = buf.managed.dl_tensor
#
for ndim in (2, 1, 0):
Expand All @@ -571,7 +571,7 @@ def testNdim(self):
del dltensor

def testShape(self):
buf = DLPackBuf('i', [0,1,2,3])
buf = DLPackCPUBuf('i', [0,1,2,3])
dltensor = buf.managed.dl_tensor
#
dltensor.ndim = 1
Expand All @@ -589,7 +589,7 @@ def testShape(self):
del dltensor

def testStrides(self):
buf = DLPackBuf('i', range(8))
buf = DLPackCPUBuf('i', range(8))
dltensor = buf.managed.dl_tensor
#
for order in ('C', 'F'):
Expand All @@ -602,7 +602,7 @@ def testStrides(self):
del dltensor

def testContiguous(self):
buf = DLPackBuf('i', range(8))
buf = DLPackCPUBuf('i', range(8))
dltensor = buf.managed.dl_tensor
#
dltensor.ndim, dltensor.shape, dltensor.strides = \
Expand All @@ -622,7 +622,7 @@ def testContiguous(self):
del dltensor

def testByteOffset(self):
buf = DLPackBuf('B', [0,1,2,3])
buf = DLPackCPUBuf('B', [0,1,2,3])
dltensor = buf.managed.dl_tensor
#
dltensor.ndim = 1
Expand Down
0