Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added mlx::core::version() returning std::string(MLX_VERSION) #1819

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions mlx/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include "mlx/primitives.h"
#include "mlx/utils.h"

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

// clang-format off
#define SERIALIZE_PRIMITIVE(primitive, ...) \
{ \
Expand Down Expand Up @@ -379,7 +376,7 @@ struct PrimitiveFactory {
};

void write_header(Writer& os, int count, bool shapeless) {
serialize(os, std::string(TOSTRING(MLX_VERSION)));
serialize(os, version());
serialize(os, count);
serialize(os, shapeless);
}
Expand Down
7 changes: 7 additions & 0 deletions mlx/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "mlx/dtype.h"
#include "mlx/stream.h"

#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)

namespace mlx::core {

using StreamOrDevice = std::variant<std::monostate, Stream, Device>;
Expand Down Expand Up @@ -112,6 +115,10 @@ inline int next_power_of_2(int n) {
return pow(2, std::ceil(std::log2(n)));
}

std::string version() {
return std::string(TOSTRING(MLX_VERSION));
}

namespace env {

int get_var(const char* name, int default_value);
Expand Down