Lazy metal_device_ initialization (#185)

This ensures it is defined when the Scheduler needs it.
This commit is contained in:
Ronan Collobert
2023-12-15 16:06:46 -08:00
committed by GitHub
parent f24200db2c
commit 83f266c44c

View File

@@ -17,8 +17,6 @@ namespace fs = std::filesystem;
namespace mlx::core::metal {
static Device metal_device_;
namespace {
// TODO nicer way to set this or possibly expose as an environment variable
@@ -240,6 +238,7 @@ MTL::ComputePipelineState* Device::get_kernel(
}
Device& device(mlx::core::Device) {
static Device metal_device_;
return metal_device_;
}