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

Method test_repeat

python/tests/test_ops.py:2496–2515  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2494 self.assertEqual(d[-1], b)
2495
2496 def test_repeat(self):
2497 # Setup data for the tests
2498 data = mx.array([[[13, 3], [16, 6]], [[14, 4], [15, 5]], [[11, 1], [12, 2]]])
2499 # Test repeat 0 times
2500 self.assertCmpNumpy([data, 0], mx.repeat, np.repeat)
2501 # Test repeat along axis 0
2502 self.assertCmpNumpy([data, 2], mx.repeat, np.repeat, axis=0)
2503 # Test repeat along axis 1
2504 self.assertCmpNumpy([data, 2], mx.repeat, np.repeat, axis=1)
2505 # Test repeat along the last axis (default)
2506 self.assertCmpNumpy([data, 2], mx.repeat, np.repeat)
2507 # Test repeat with a 1D array along axis 0
2508 self.assertCmpNumpy([mx.array([1, 3, 2]), 3], mx.repeat, np.repeat, axis=0)
2509 # Test repeat with a 2D array along axis 0
2510 self.assertCmpNumpy(
2511 [mx.array([[1, 2, 3], [4, 5, 4], [0, 1, 2]]), 2],
2512 mx.repeat,
2513 np.repeat,
2514 axis=0,
2515 )
2516
2517 def test_tensordot(self):
2518 # No fp16 matmuls on common cpu backend

Callers

nothing calls this directly

Calls 2

assertCmpNumpyMethod · 0.80
arrayMethod · 0.60

Tested by

no test coverage detected