Something went wrong. Try again.
Teaching myself about embeddings as I read hands-on large language models
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import mlx.core as mximport numpyimport torch
from common.benchmark import benchmarkfrom common.device import collect_device_report
def test_device_report_populated(): report = collect_device_report() assert report["cpu"] is not None assert report["mlx"] is not None assert report["numpy"] is not None assert report["torch"] is not None
def test_torch_report_correct(): report = collect_device_report() assert torch.backends.mps.is_available() is not None assert report["torch"]["mps_available"] == torch.backends.mps.is_available()
def test_mx_report_correct(): report = collect_device_report() assert mx.metal.is_available() is not None assert report["mlx"]["metal_available"] == mx.metal.is_available()
def test_numpy_functional(): a = numpy.array([1, 2, 3]) assert a.sum() == 6
def test_benchmark_works(): result = benchmark( name="test", func=lambda: 10 * 2, warmup_iterations=2, timed_iterations=10, )
assert result is not None assert result.name == "test" assert result.mean > 0 assert result.median > 0 assert result.minimum > 0 assert result.maximum > 0 assert result.p95 > 0