Recover Apple Silicon benchmark payload
This commit is contained in:
parent
1ca441a3f3
commit
5bf74072e1
2 changed files with 399 additions and 0 deletions
23
test_embedding.py
Normal file
23
test_embedding.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import torch
|
||||
import mlx.core as mx
|
||||
from unsloth.kernels.mlx.bridge import mlx_to_torch
|
||||
|
||||
arr = mx.array([[1, 2, 3], [4, 5, 6]], dtype=mx.int32)
|
||||
tensor = mlx_to_torch(arr)
|
||||
print("Tensor:", tensor)
|
||||
print("Tensor device:", tensor.device)
|
||||
|
||||
emb = torch.nn.Embedding(10, 5).to("mps")
|
||||
try:
|
||||
res = emb(tensor.to("mps"))
|
||||
print("Success")
|
||||
except Exception as e:
|
||||
print("Error:", e)
|
||||
|
||||
# Test with a clone
|
||||
tensor2 = tensor.clone()
|
||||
try:
|
||||
res = emb(tensor2.to("mps"))
|
||||
print("Success with clone")
|
||||
except Exception as e:
|
||||
print("Error with clone:", e)
|
||||
Loading…
Add table
Add a link
Reference in a new issue