MCPcopy Create free account
hub / github.com/ml-explore/mlx / test_dlpack

Method test_dlpack

python/tests/test_array.py:2001–2013  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1999 self.assertEqual(z.item(), 3)
2000
2001 def test_dlpack(self):
2002 x = mx.array(1, dtype=mx.int32)
2003 y = np.from_dlpack(x)
2004 self.assertTrue(mx.array_equal(y, x))
2005
2006 x = mx.array([[1.0, 2.0], [3.0, 4.0]])
2007 y = np.from_dlpack(x)
2008 self.assertTrue(mx.array_equal(y, x))
2009
2010 x = mx.arange(16).reshape(4, 4)
2011 x = x[::2, ::2]
2012 y = np.from_dlpack(x)
2013 self.assertTrue(mx.array_equal(y, x))
2014
2015 def test_getitem_with_list(self):
2016 a = mx.array([1, 2, 3, 4, 5])

Callers

nothing calls this directly

Calls 1

arrayMethod · 0.60

Tested by

no test coverage detected