2024-05-23 17:04:02 -07:00
|
|
|
// Copyright © 2023-2024 Apple Inc.
|
2023-11-30 11:12:53 -08:00
|
|
|
|
2024-03-18 20:12:25 -07:00
|
|
|
#include <nanobind/nanobind.h>
|
2023-11-29 10:52:08 -08:00
|
|
|
|
2025-09-09 07:41:05 +09:00
|
|
|
#include "mlx/version.h"
|
2023-11-29 10:52:08 -08:00
|
|
|
|
2025-09-09 07:41:05 +09:00
|
|
|
namespace mx = mlx::core;
|
2024-03-18 20:12:25 -07:00
|
|
|
namespace nb = nanobind;
|
|
|
|
|
2025-02-11 14:45:02 -08:00
|
|
|
void init_mlx_func(nb::module_&);
|
2024-03-18 20:12:25 -07:00
|
|
|
void init_array(nb::module_&);
|
|
|
|
void init_device(nb::module_&);
|
|
|
|
void init_stream(nb::module_&);
|
|
|
|
void init_metal(nb::module_&);
|
2025-08-20 17:20:22 -07:00
|
|
|
void init_cuda(nb::module_&);
|
2025-03-21 07:25:12 -07:00
|
|
|
void init_memory(nb::module_&);
|
2024-03-18 20:12:25 -07:00
|
|
|
void init_ops(nb::module_&);
|
|
|
|
void init_transforms(nb::module_&);
|
|
|
|
void init_random(nb::module_&);
|
|
|
|
void init_fft(nb::module_&);
|
|
|
|
void init_linalg(nb::module_&);
|
|
|
|
void init_constants(nb::module_&);
|
|
|
|
void init_fast(nb::module_&);
|
2024-05-23 17:04:02 -07:00
|
|
|
void init_distributed(nb::module_&);
|
2024-12-24 11:19:13 -08:00
|
|
|
void init_export(nb::module_&);
|
2024-03-18 20:12:25 -07:00
|
|
|
|
|
|
|
NB_MODULE(core, m) {
|
2023-12-14 11:48:00 +08:00
|
|
|
m.doc() = "mlx: A framework for machine learning on Apple silicon.";
|
2023-11-29 10:52:08 -08:00
|
|
|
|
2024-03-18 20:12:25 -07:00
|
|
|
auto reprlib_fix = nb::module_::import_("mlx._reprlib_fix");
|
|
|
|
nb::module_::import_("mlx._os_warning");
|
|
|
|
nb::set_leak_warnings(false);
|
2023-11-29 10:52:08 -08:00
|
|
|
|
2025-02-11 14:45:02 -08:00
|
|
|
init_mlx_func(m);
|
2023-11-29 10:52:08 -08:00
|
|
|
init_device(m);
|
|
|
|
init_stream(m);
|
|
|
|
init_array(m);
|
|
|
|
init_metal(m);
|
2025-08-20 17:20:22 -07:00
|
|
|
init_cuda(m);
|
2025-03-21 07:25:12 -07:00
|
|
|
init_memory(m);
|
2023-11-29 10:52:08 -08:00
|
|
|
init_ops(m);
|
|
|
|
init_transforms(m);
|
|
|
|
init_random(m);
|
|
|
|
init_fft(m);
|
2023-12-27 04:42:04 +01:00
|
|
|
init_linalg(m);
|
2024-01-11 20:17:29 +05:30
|
|
|
init_constants(m);
|
2024-03-18 20:12:25 -07:00
|
|
|
init_fast(m);
|
2024-05-23 17:04:02 -07:00
|
|
|
init_distributed(m);
|
2024-12-24 11:19:13 -08:00
|
|
|
init_export(m);
|
2024-02-14 17:14:58 -05:00
|
|
|
|
2025-09-09 07:41:05 +09:00
|
|
|
m.attr("__version__") = mx::version();
|
2023-11-29 10:52:08 -08:00
|
|
|
}
|