mirror of
https://github.com/ml-explore/mlx.git
synced 2025-10-20 01:18:12 +08:00
Switch to nanobind (#839)
* mostly builds * most tests pass * fix circle build * add back buffer protocol * includes * fix for py38 * limit to cpu device * include * fix stubs * move signatures for docs * stubgen + docs fix * doc for compiled function, comments
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
// Copyright © 2023 Apple Inc.
|
||||
// Conbright © 2023-2024 Apple Inc.
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <nanobind/nanobind.h>
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
|
||||
namespace py = pybind11;
|
||||
namespace nb = nanobind;
|
||||
|
||||
void init_array(py::module_&);
|
||||
void init_device(py::module_&);
|
||||
void init_stream(py::module_&);
|
||||
void init_metal(py::module_&);
|
||||
void init_ops(py::module_&);
|
||||
void init_transforms(py::module_&);
|
||||
void init_random(py::module_&);
|
||||
void init_fft(py::module_&);
|
||||
void init_linalg(py::module_&);
|
||||
void init_constants(py::module_&);
|
||||
void init_extensions(py::module_&);
|
||||
void init_utils(py::module_&);
|
||||
void init_array(nb::module_&);
|
||||
void init_device(nb::module_&);
|
||||
void init_stream(nb::module_&);
|
||||
void init_metal(nb::module_&);
|
||||
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_&);
|
||||
|
||||
PYBIND11_MODULE(core, m) {
|
||||
NB_MODULE(core, m) {
|
||||
m.doc() = "mlx: A framework for machine learning on Apple silicon.";
|
||||
|
||||
auto reprlib_fix = py::module_::import("mlx._reprlib_fix");
|
||||
py::module_::import("mlx._os_warning");
|
||||
auto reprlib_fix = nb::module_::import_("mlx._reprlib_fix");
|
||||
nb::module_::import_("mlx._os_warning");
|
||||
nb::set_leak_warnings(false);
|
||||
|
||||
init_device(m);
|
||||
init_stream(m);
|
||||
@@ -36,8 +36,7 @@ PYBIND11_MODULE(core, m) {
|
||||
init_fft(m);
|
||||
init_linalg(m);
|
||||
init_constants(m);
|
||||
init_extensions(m);
|
||||
init_utils(m);
|
||||
init_fast(m);
|
||||
|
||||
m.attr("__version__") = TOSTRING(_VERSION_);
|
||||
}
|
||||
|
Reference in New Issue
Block a user