mlx 0.1.0 copy "mlx: ^0.1.0" to clipboard
mlx: ^0.1.0 copied to clipboard

PlatformmacOS

Dart bindings for Apple's MLX array framework on Apple Silicon: tensors, neural-network layers, FFT, quantization, and safetensors — via FFI to mlx-c.

example/example.dart

// Minimal `mlx` example: build arrays, run ops, and a tiny neural-net forward.
//
// Run from packages/mlx:
//   dart run example/example.dart
import 'package:mlx/mlx.dart';

void main() {
  // Create arrays from literal data and from a shape.
  final a = MlxArray.fromList(<double>[1, 2, 3, 4], <int>[2, 2]);
  final b = ones(<int>[2, 2]);

  // Elementwise add (or `a + b`) and a matrix multiply.
  final sum = add(a, b);
  final product = matmul(a, b);

  // MLX is lazy — force evaluation before reading the results.
  eval(<MlxArray>[sum, product]);
  print('a + b =\n$sum');
  print('a @ b =\n$product');

  // A tiny forward pass through one Linear layer (2 -> 3).
  final layer = Linear(2, 3);
  final x = MlxArray.fromList(<double>[1, 2], <int>[1, 2]);
  final y = layer(x);
  eval(<MlxArray>[y]);
  print('Linear(2, 3) output shape: ${y.shape}');

  print('mlx core version: ${mlxVersion()}');
}
1
likes
160
points
86
downloads

Documentation

API reference

Publisher

verified publisherksh.dev

Weekly Downloads

Dart bindings for Apple's MLX array framework on Apple Silicon: tensors, neural-network layers, FFT, quantization, and safetensors — via FFI to mlx-c.

Repository (GitHub)
View/report issues

Topics

#mlx #machine-learning #ffi #apple-silicon #tensors

License

MIT (license)

Dependencies

ffi

More

Packages that depend on mlx