import mlx.core as mx import numpy import torch from common.benchmark import benchmark from 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