oxideai / mlx-rs

Unofficial Rust bindings to Apple's mlx framework
https://oxideai.github.io/mlx-rs/
Apache License 2.0
51 stars 4 forks source link

added traits and macro to help create 1d, 2d, and 3d arrays #74

Closed minghuaw closed 3 months ago

minghuaw commented 3 months ago

This allows creating array with up to 3 dims using the macro array!

use mlx_rs::array;

// Create a 1D array
let a1 = array![1, 2, 3];

// Create a 2D array
let a2 = array![
    [1, 2, 3], 
    [4, 5, 6]
];

// Create a 3D array
let a3 = array![
    [
        [1, 2, 3], 
        [4, 5, 6]
    ], 
    [
        [7, 8, 9], 
        [10, 11, 12]
    ]
];

Dependencies