mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-26 18:51:14 +08:00

* implemented vector_norm in cpp added linalg to mlx * implemented vector_norm python binding * renamed vector_norm to norm, implemented norm without provided ord * completed the implementation of the norm * added tests * removed unused import in linalg.cpp * updated python bindings * added some tests for python bindings * handling inf, -inf as numpy does, more extensive tests of compatibility with numpy * added better docs and examples * refactored mlx.linalg.norm bindings * reused existing util for implementation of linalg.norm * more tests * fixed a bug with no ord and axis provided * removed unused imports * some style and API consistency updates to linalg norm * remove unused includes * fix python tests * fixed a bug with frobenius norm of a complex-valued matrix * complex for vector too --------- Co-authored-by: Awni Hannun <awni@apple.com>
36 lines
803 B
C++
36 lines
803 B
C++
// Copyright © 2023 Apple Inc.
|
|
|
|
#include <pybind11/pybind11.h>
|
|
|
|
#define STRINGIFY(x) #x
|
|
#define TOSTRING(x) STRINGIFY(x)
|
|
|
|
namespace py = pybind11;
|
|
|
|
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_&);
|
|
|
|
PYBIND11_MODULE(core, m) {
|
|
m.doc() = "mlx: A framework for machine learning on Apple silicon.";
|
|
|
|
auto reprlib_fix = py::module_::import("mlx._reprlib_fix");
|
|
|
|
init_device(m);
|
|
init_stream(m);
|
|
init_array(m);
|
|
init_metal(m);
|
|
init_ops(m);
|
|
init_transforms(m);
|
|
init_random(m);
|
|
init_fft(m);
|
|
init_linalg(m);
|
|
m.attr("__version__") = TOSTRING(_VERSION_);
|
|
}
|