Utilities for easing the development of machine learning inference libraries and applications on iOS and macOS using the MLX framework.
- iOS 18.0+
- macOS 15.0+
Add MLXUtilsLibrary to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/yourusername/MLXUtilsLibrary.git", from: "0.0.1")
]Then add it to your target dependencies:
.target(
name: "YourTarget",
dependencies: ["MLXUtilsLibrary"]
)import MLXUtilsLibrary
import MLX
// Load a single .npy file
if let arrays = NpyzReader.read(fileFromPath: npyFileURL) {
let array = arrays["npy"] // MLXArray
print(array?.shape)
}
// Load a .npz archive (containing multiple arrays)
if let arrays = NpyzReader.read(fileFromPath: npzFileURL) {
for (name, array) in arrays {
print("\(name): \(array.shape)")
}
}
// Load from Data
let data = try Data(contentsOf: fileURL)
let arrays = NpyzReader.read(data: data, isPacked: true)- NpyzReader: Load NumPy
.npyand.npzfiles directly into MLX arrays - Support for all common data types (bool, int8-64, uint8-64, float32/64)
- Handles both little-endian and big-endian formats
- Based on swift-npy
- BenchmarkTimer: Performance measurement utilities for profiling ML operations
- MLXArray Extensions: Enhanced debug printing for MLX arrays
- Logging Utilities: Convenient logging helpers
See LICENSE file for details.