mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-19 00:04:41 +08:00
add base kwarg to rope (#186)
This commit is contained in:
@@ -463,6 +463,21 @@ class TestNN(mlx_tests.MLXTestCase):
|
||||
mx.array([0.8651, -0.3034, 0.0000, 0.3752]),
|
||||
)
|
||||
|
||||
def test_rope(self):
|
||||
for kwargs in [{}, {"traditional": False}, {"base": 10000}]:
|
||||
rope = nn.RoPE(4, **kwargs)
|
||||
shape = (1, 3, 4)
|
||||
x = mx.random.uniform(shape=shape)
|
||||
y = rope(x)
|
||||
self.assertTrue(y.shape, shape)
|
||||
self.assertTrue(y.dtype, mx.float32)
|
||||
|
||||
y = rope(x, offset=3)
|
||||
self.assertTrue(y.shape, shape)
|
||||
|
||||
y = rope(x.astype(mx.float16))
|
||||
self.assertTrue(y.dtype, mx.float16)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user