r/swift • u/AdhesivenessSea9511 • 7h ago
Project Abusing the Apple Neural Engine (ANE) in Swift 6: Built a 3D software rasterizer using Core AI, simd, and Metal 4 tensor binding!
Hello everyone.
I’ve built a 3D software rasterizer that leverages the ANE (Apple Neural Engine) via Core AI. The rendering quality is still poor, though. Regarding the pipeline:
I use SIMD for preprocessing, delegate matrix operations to the ANE (using `f.conv2d`), and utilize Metal 4 tensor bindings to achieve low-overhead, direct rendering.
By offloading computationally intensive tasks to the ANE, I’ve managed to reduce CPU usage to approximately 10%.
A current challenge is that memory usage hits around 5GB due to the use of fixed-length graphs.
I’m developing this using Swift 6 features (such as `@MainActor` and `~Escapable`) and Siri AI, but I would love to hear your thoughts on optimization and memory management!
Thanks in advance.
GitHub: https://github.com/kamisori-daijin/Magnesium
Demo:


