(self)
| 57 | ) |
| 58 | |
| 59 | def test_binary_ops(self): |
| 60 | shape = (3, 3) |
| 61 | a = mx.random.normal(shape=shape) |
| 62 | b = mx.random.normal(shape=shape) |
| 63 | |
| 64 | a_double = a.astype(mx.float64, stream=mx.cpu) |
| 65 | b_double = b.astype(mx.float64, stream=mx.cpu) |
| 66 | |
| 67 | ops = [ |
| 68 | mx.add, |
| 69 | mx.arctan2, |
| 70 | mx.divide, |
| 71 | mx.multiply, |
| 72 | mx.subtract, |
| 73 | mx.logical_and, |
| 74 | mx.logical_or, |
| 75 | mx.remainder, |
| 76 | mx.maximum, |
| 77 | mx.minimum, |
| 78 | mx.power, |
| 79 | mx.equal, |
| 80 | mx.greater, |
| 81 | mx.greater_equal, |
| 82 | mx.less, |
| 83 | mx.less_equal, |
| 84 | mx.not_equal, |
| 85 | mx.logaddexp, |
| 86 | ] |
| 87 | for op in ops: |
| 88 | if mx.default_device() == mx.gpu: |
| 89 | with self.assertRaises(ValueError): |
| 90 | op(a_double, b_double) |
| 91 | continue |
| 92 | y = op(a, b) |
| 93 | y_double = op(a_double, b_double) |
| 94 | self.assertTrue( |
| 95 | mx.allclose(y, y_double.astype(mx.float32, mx.cpu), equal_nan=True) |
| 96 | ) |
| 97 | |
| 98 | def test_where(self): |
| 99 | shape = (3, 3) |
nothing calls this directly
no outgoing calls
no test coverage detected