A lightweight ‘Accelerated’ matrix library for Swift
Today we released a super lightweight “Accelerated Matrix Library for Swift”. We call it MatrixLite, and it aims to be the lightweight cousin of Surge, with about 90% of the core functionality, but at a fraction of the size.
Why another matrix library?
If you look around the internets a bit, you’ll find several good matrix libraries for Swift out there (like this one, this one, this one, and even this one). Each one has its own merits and issues. At Set, we needed something super lightweight, but that had all the features required for basic neural network architectures that would run (and even train) on the device. We were also concerned about support: since Swift and its package ecosystem is still so young, new projects pop-up and die all the time. We needed to be sure we’d have something that we could maintain ourselves, and ensure it received updates as new Swift versions rolled out. So MatrixLite is our answer to a user-friendly matrix library that supports transposing, slicing, dicing, multiple initializers and converters, and various reducers and mathematical functions. It currently supports most of the methods required for basic artificial neural network (ANN) architectures and extreme learning machines (ELM).
Matrices are the workhorse of many machine learning/ANN workflows, so optimization and API simplification at the level of data representation has far-reaching implications for complex computational workflows. `MatrixLite` is designed to be fast, super lightweight, and most importantly, easy to use. Wherever possible, we take advantage of SIMD instructions and data types and we take advantage of Apple’s Accelerate framework throughout. To facilitate rapid model development and prototyping, MatrixLite wraps all of this computational power under a much more readable and ‘Swifty’ API. It’s also really easy to copypasta functions and methods from the library, so if you just need one part or another, feel free to take what you need for your own projects… we’d love to hear what you build 😀.
So check out our official open source release of MatrixLite over here, and let us know what you think. If you find it useful, or you have some issues, ideas, merge requests, or complaints, also let us know. And of course, if you know of any other matrix implementations for Swift, we’d love to hear about that too.