Add public Cxxmlx target for MLX C++ sources#425
Draft
a1091150 wants to merge 2 commits into
Draft
Conversation
Move ownership of the vendored MLX C++ sources from Cmlx into a new public Cxxmlx target. This lets downstream C++ consumers depend on Cxxmlx directly and include MLX headers with paths like <mlx/mlx.h>. Cmlx now owns only the mlx-c wrapper sources and depends on Cxxmlx for the underlying C++ implementation. Update the package manifest, submodule path, header layout, maintenance scripts, docs, and Xcode project settings to use Source/Cxxmlx for MLX C++ sources, generated sources, fmt, json, and metal-cpp.
Mirror the metal-cpp Foundation, Metal, MetalFX, and QuartzCore headers into Cxxmlx's public include directory so downstream SwiftPM targets can compile custom MLX C++ primitives without adding unsafe header search paths. MLX public Metal backend headers, such as mlx/backend/metal/device.h, include Metal C++ headers like <Metal/Metal.hpp>. Since SwiftPM does not expose a dependency target's private header search paths to consumers, Cxxmlx's public headers need to be self-contained under publicHeadersPath. Update tools/update-mlx.sh to refresh these metal-cpp public header mirrors alongside the MLX C++ header mirror.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
This PR separates MLX C++ from Cmlx into a new public Cxxmlx target and exposes metal-cpp header. Allow users write custom mlx c++ extension (mlx::core::Primitive) without rewriting into swift version or fast kernel code.
Reproduce the changes
git mvto move files from Cmlx target to Cxxmlx target.#include <mlx/mlx.h>works.Source/Cxxmlx/include/mlx/Source/Cxxmlx/include/, Foundation, Metal, MetalFX and QuartzCoretools/update-mlx.shto update these public headers.I have tried on my 3DGS private project, Linux machines have not tested yet.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes