A Swift DSL for gluing Apple's MPSCNN into something usable
Forge wraps Apple's verbose Metal Performance Shaders CNN API with a chainable Swift syntax and some missing layers.

What it does
Forge is a helper library that sits on top of Apple’s MPSCNN framework, offering conversion utilities between Metal’s 16-bit float textures and Swift [Float] arrays, plus a domain-specific language for defining neural networks. It also fills in gaps that MPSCNN left open—custom layers like depth-wise convolution, preprocessing kernels for color operations, and debugging tools for inspecting MTLTexture contents.
The interesting bit
The -> operator chaining is the real sell: you can pipe an Input() through Resize, Convolution, MaxPooling, and Dense layers in a single readable expression, which the README demonstrates with a side-by-side MNIST example showing the DSL version against raw MPSCNN boilerplate. The author also notes that hand-rolled Metal networks remain faster than Core ML, even if Core ML made this toolkit largely unnecessary.
Key highlights
- Chainable Swift DSL (
input --> Convolution(...) --> Softmax()) - Custom layers: depth-wise convolution, transpose channels, deconvolution (marked “coming soon”)
- Preprocessing kernels: subtract mean color, RGB→gray, RGB→BGR
- Example apps included: MNIST (LeNet-5), Inception-v3, Tiny YOLO, MobileNets (20 FPS on iPhone 6s)
- Requires Xcode 9, iOS 10+, and a physical A8+ device—simulator builds fail because Metal
Caveats
- Unmaintained: author explicitly stopped development; uses an older MPSCNN API Apple no longer supports
- Experimental: README warns “a lot of the code… is still experimental and subject to change”
- iOS 11 gaps: does not use batch normalization parameter loading or MPS data-source weight loading
- Deconvolution promised as “coming soon” with no delivery date visible
Verdict
Worth studying if you’re maintaining legacy iOS Metal inference code or want to see how a DSL can tame Apple’s low-level GPU APIs. Skip it for new projects—Core ML exists, and the author himself points to his newer library for current MobileNet/SSD work.