mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-04 15:04:40 +08:00
Fix complex power and print (#2286)
* fix complex power and print * fix complex matmul shape
This commit is contained in:
@@ -1195,6 +1195,16 @@ class TestBlas(mlx_tests.MLXTestCase):
|
||||
c_np = np.matmul(np.array(a).T, b)
|
||||
self.assertTrue(np.allclose(c, c_np))
|
||||
|
||||
# Check shapes
|
||||
a = mx.random.normal((2, 3)).astype(mx.complex64)
|
||||
b = mx.random.normal((3,))
|
||||
self.assertEqual((a @ b).shape, (2,))
|
||||
|
||||
a = mx.random.normal((2, 3)).astype(mx.complex64)
|
||||
b = mx.random.normal((3,))
|
||||
c = mx.random.normal((2,))
|
||||
self.assertEqual(mx.addmm(c, a, b).shape, (2,))
|
||||
|
||||
def test_complex_gemm(self):
|
||||
M = 16
|
||||
K = 50
|
||||
|
@@ -3078,6 +3078,13 @@ class TestOps(mlx_tests.MLXTestCase):
|
||||
)
|
||||
self.assertTrue(np.allclose(mx.rsqrt(x), 1.0 / np.sqrt(x)))
|
||||
|
||||
def test_complex_power(self):
|
||||
out = mx.power(mx.array(0j), 2)
|
||||
self.assertEqual(out.item(), 0j)
|
||||
|
||||
out = mx.power(mx.array(0j), float("nan"))
|
||||
self.assertTrue(mx.isnan(out))
|
||||
|
||||
|
||||
class TestBroadcast(mlx_tests.MLXTestCase):
|
||||
def test_broadcast_shapes(self):
|
||||
|
Reference in New Issue
Block a user