| 26 | #define DEPRECATE(oldfn, newfn) static bool dep = DEPRECATE(oldfn, newfn) |
| 27 | |
| 28 | void init_metal(nb::module_& m) { |
| 29 | nb::module_ metal = m.def_submodule("metal", "mlx.metal"); |
| 30 | metal.def( |
| 31 | "is_available", |
| 32 | &mx::metal::is_available, |
| 33 | R"pbdoc( |
| 34 | Check if the Metal back-end is available. |
| 35 | )pbdoc"); |
| 36 | metal.def("get_active_memory", []() { |
| 37 | DEPRECATE("mx.metal.get_active_memory", "mx.get_active_memory"); |
| 38 | return mx::get_active_memory(); |
| 39 | }); |
| 40 | metal.def("get_peak_memory", []() { |
| 41 | DEPRECATE("mx.metal.get_peak_memory", "mx.get_peak_memory"); |
| 42 | return mx::get_peak_memory(); |
| 43 | }); |
| 44 | metal.def("reset_peak_memory", []() { |
| 45 | DEPRECATE("mx.metal.reset_peak_memory", "mx.reset_peak_memory"); |
| 46 | mx::reset_peak_memory(); |
| 47 | }); |
| 48 | metal.def("get_cache_memory", []() { |
| 49 | DEPRECATE("mx.metal.get_cache_memory", "mx.get_cache_memory"); |
| 50 | return mx::get_cache_memory(); |
| 51 | }); |
| 52 | metal.def( |
| 53 | "set_memory_limit", |
| 54 | [](size_t limit) { |
| 55 | DEPRECATE("mx.metal.set_memory_limit", "mx.set_memory_limit"); |
| 56 | return mx::set_memory_limit(limit); |
| 57 | }, |
| 58 | "limit"_a); |
| 59 | metal.def( |
| 60 | "set_cache_limit", |
| 61 | [](size_t limit) { |
| 62 | DEPRECATE("mx.metal.set_cache_limit", "mx.set_cache_limit"); |
| 63 | return mx::set_cache_limit(limit); |
| 64 | }, |
| 65 | "limit"_a); |
| 66 | metal.def( |
| 67 | "set_wired_limit", |
| 68 | [](size_t limit) { |
| 69 | DEPRECATE("mx.metal.set_wired_limit", "mx.set_wired_limit"); |
| 70 | return mx::set_wired_limit(limit); |
| 71 | }, |
| 72 | "limit"_a); |
| 73 | metal.def("clear_cache", []() { |
| 74 | DEPRECATE("mx.metal.clear_cache", "mx.clear_cache"); |
| 75 | mx::clear_cache(); |
| 76 | }); |
| 77 | metal.def( |
| 78 | "start_capture", |
| 79 | &mx::metal::start_capture, |
| 80 | "path"_a, |
| 81 | R"pbdoc( |
| 82 | Start a Metal capture. |
| 83 | |
| 84 | Args: |
| 85 | path (str): The path to save the capture which should have |
no test coverage detected