iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.79k stars 603 forks source link

[Ideas] Prototype integration into Unity game engine #14480

Open ScottTodd opened 1 year ago

ScottTodd commented 1 year ago

(filing this to track ideas and see if there is community interest)

Background

IREE is designed to take the "ML" out of "ML deployment" and just turn "running an ML model" into "running some code". The low level runtime code should be well suited for integration into user applications like mobile phone apps and game engines that target a wide range of devices.

The Unity game engine has its own custom libraries for working with ML models:

I've personally had my eye on game engine integration of ML workload local execution for years, and I think there's potential to dramatically simplify some workflows while unlocking more performance and features.

Advantages to a generic compilation approach:

Integration ideas

Ergonomics are critically important for a game engine / middleware library, so any integration would need to feel native. We can pattern match to how other large assets are handled (e.g. baked lighting, texture recompression).

Codegen ideas

IREE's compiler can generate code for a variety of hardware targets, but Unity also has its own abstractions that we could target instead. These could integrate more directly with existing scheduling mechanisms in the game engine. Performance is tricky to predict... Unity's own compilers/runtime code could either find or miss certain classes of optimizations.

fire commented 3 days ago

For tracking we have implement a subset of these requirements here https://github.com/iree-gd/iree.gd