mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-03 14:24:44 +08:00
feat: Added dlpack device (#1165)
* feat: Added dlpack device * feat: Added device_id to dlpack device * feat: Added device_id to dlpack device * doc: updated conversion docs * doc: updated numpy.rst dlpack information * doc: updated numpy.rst dlpack information * Update docs/src/usage/numpy.rst * Update docs/src/usage/numpy.rst --------- Co-authored-by: Venkat Ramnan Kalyanakumar <venkatramnankalyanakumar@Venkats-MacBook-Air.local> Co-authored-by: Awni Hannun <awni.hannun@gmail.com>
This commit is contained in:
@@ -161,6 +161,19 @@ class TestInequality(mlx_tests.MLXTestCase):
|
||||
self.assertTrue(a != b)
|
||||
self.assertTrue(a != c)
|
||||
|
||||
def test_dlx_device_type(self):
|
||||
a = mx.array([1, 2, 3])
|
||||
device_type, device_id = a.__dlpack_device__()
|
||||
self.assertIn(device_type, [1, 8])
|
||||
self.assertEqual(device_id, 0)
|
||||
|
||||
if device_type == 8:
|
||||
# Additional check if Metal is supposed to be available
|
||||
self.assertTrue(mx.metal.is_available())
|
||||
elif device_type == 1:
|
||||
# Additional check if CPU is the fallback
|
||||
self.assertFalse(mx.metal.is_available())
|
||||
|
||||
def test_tuple_not_equals_array(self):
|
||||
a = mx.array([1, 2, 3])
|
||||
b = (1, 2, 3)
|
||||
|
Reference in New Issue
Block a user