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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,8 +17,6 @@ namespace fs = std::filesystem;
namespace mlx::core::metal { namespace mlx::core::metal {
static Device metal_device_;
namespace { namespace {
// TODO nicer way to set this or possibly expose as an environment variable // 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) { Device& device(mlx::core::Device) {
static Device metal_device_;
return metal_device_; return metal_device_;
} }