Skip to content

Commit

Permalink
update: Update to revamped c binding (#147)
Browse files Browse the repository at this point in the history
* update mlx-c

* removed shim

* partial updates to new c api

* update fft

* update dtype and device

* updated indexing

* updated index and fft ops to take impl AsRef<Array>

* use custom Result type alias

* avoid conflict

* updated more mods

* update logical

* updated optmizers

* updated compile

* updated transforms

* updated shapes

* updated quantization

* added more linalg fns

* updated io

* need clone

* impl Clone using mlx_array_set

* add comments about Vec<&Array>

* clippy and fmt

* revert back to cloning

* revert to perform type casting in item

* default all fft/ifft on cpu for now

* pass all tests

* try fix CI problem

* Revert "try fix CI problem"

This reverts commit 3c8ca26.

* Use newer Xcode

* free new mlx_array if cloning fails

* added guard

* impl guard and guarded for vec pairs

* make most ops return result regardless of underlying c++ impl

* renamed try_op to try_from_op

* update index to use guarded

* update to Guarded

* update to Guarded op

* update remaning ops to use Guarded op

* added test_clip_grad_norm

* clippy and fmt

* fix doctest

* update mlx-c to tags/v0.1.0

* remove device = "cpu"

* remove affine_quantize which was removed from python and swift as well

* change newtype wrapper to type alias

* fix latest clippy warnings

* cargo fmt

* remove unused static

* update mlx-sys crate version to match mlx-c

* re-export ModuleParameters macro

* changing test_celu to follow the python version

* try using gh hosted mac runners

* try setting CMAKE_OSX_DEPLOYMENT_TARGET

* try setting runner to macos-15

* try setting xcode version to 15.2

* try setting xcode version to 16.1

* try xcode 16.1 on macos-14

* try macos-14 and xcode 16.0

* need macos-15

* try blaze/macos-15 runners

---------

Co-authored-by: David Chavez <[email protected]>
  • Loading branch information
minghuaw and dcvz committed Dec 11, 2024
1 parent fcbf564 commit 52568a2
Show file tree
Hide file tree
Showing 72 changed files with 4,170 additions and 4,257 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ on:
- main
pull_request:
types: [opened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
rustfmt-check:
runs-on: blaze/macos-14
runs-on: blaze/macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Xcode
run: sudo xcodes select 16.0
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand All @@ -26,7 +29,7 @@ jobs:
run: cargo clippy -- -D warnings

tests:
runs-on: blaze/macos-14
runs-on: blaze/macos-15
strategy:
matrix:
rust: [ stable, 1.75.0 ]
Expand All @@ -40,6 +43,8 @@ jobs:
uses: actions/checkout@v4
with:
submodules: true
- name: Setup Xcode
run: sudo xcodes select 16.0
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
Expand All @@ -51,4 +56,4 @@ jobs:
with:
key: ${{ runner.os }}-${{ matrix.cache }}-${{ matrix.backend }}-${{ hashFiles('**/Cargo.toml') }}
- name: Run tests
run: cargo test --all -- --test-threads=1 # MLX is not thread safe
run: cargo test --all -- --test-threads=1 # MLX is not thread safe
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ resolver = "2"

[workspace.dependencies]
# workspace local dependencies
mlx-sys = { version = "0.0.10", path = "mlx-sys" }
mlx-sys = { version = "0.1.0", path = "mlx-sys" }
mlx-macros = { version = "0.1.0", path = "mlx-macros" }
mlx-internal-macros = { version = "0.1.0", path = "mlx-internal-macros" }
mlx-rs = { version = "0.14.0", path = "mlx-rs" }
Expand Down
2 changes: 1 addition & 1 deletion examples/mnist/src/mlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Mlp {
pub layers: Sequential,
}

impl<'a> Module<&'a Array> for Mlp {
impl Module<&Array> for Mlp {
type Error = Exception;
type Output = Array;

Expand Down
2 changes: 1 addition & 1 deletion mlx-internal-macros/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) struct BuilderStructAnalyzer<'a> {
pub err: Option<&'a syn::Path>,
}

impl<'a> BuilderStructAnalyzer<'a> {
impl BuilderStructAnalyzer<'_> {
pub fn generate_builder_struct(&self) -> proc_macro2::TokenStream {
let struct_ident = self.struct_ident;
let builder_ident = self.builder_struct_ident;
Expand Down
Loading

0 comments on commit 52568a2

Please sign in to comment.