mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 10:26:56 +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,5 +1,4 @@
|
||||
// Copyright © 2023 Apple Inc.
|
||||
|
||||
// Copyright © 2023-2024 Apple Inc.
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
@@ -122,8 +121,6 @@ void save(std::shared_ptr<io::Writer> out_stream, array a) {
|
||||
out_stream->write(magic_ver_len.str().c_str(), magic_ver_len.str().length());
|
||||
out_stream->write(header.str().c_str(), header.str().length());
|
||||
out_stream->write(a.data<char>(), a.nbytes());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Save array to file in .npy format */
|
||||
|
@@ -7,6 +7,25 @@
|
||||
namespace mlx::core {
|
||||
|
||||
struct complex64_t;
|
||||
struct complex128_t;
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool can_convert_to_complex128 =
|
||||
!std::is_same_v<T, complex128_t> && std::is_convertible_v<T, double>;
|
||||
|
||||
struct complex128_t : public std::complex<double> {
|
||||
complex128_t(double v, double u) : std::complex<double>(v, u){};
|
||||
complex128_t(std::complex<double> v) : std::complex<double>(v){};
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename = typename std::enable_if<can_convert_to_complex128<T>>::type>
|
||||
complex128_t(T x) : std::complex<double>(x){};
|
||||
|
||||
operator float() const {
|
||||
return real();
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool can_convert_to_complex64 =
|
||||
|
Reference in New Issue
Block a user