DrChainsaw / ONNXNaiveNASflux.jl

Import/export ONNX models
MIT License
44 stars 2 forks source link

Load ONNX in a framework agnostic way #90

Open jdiaz97 opened 8 months ago

jdiaz97 commented 8 months ago

This library has a very successful way to deal with ONNX files, because of this, I wanted to ask: how much of this codebase could be used to import an ONNX file and parse it into an intermediary Julia object?

I think doing that could help to eventually add support to Lux or other frameworks that could come in the future.

DrChainsaw commented 8 months ago

The CompGraph object returned by load can be seen as an "intermediary Julia object" for all intents and purposes. The NaiveNASlib docs describe it in detail. The quick tutorial has a tl;dr overview.

One way to just get the parameters out is to use the utilities of Functors.jl.

The biggest challenge I see with loading ONNX into a Flux/Lux Chain is to come up with an algorithm that converts a generic graph representation into a Chain. This can often trivially be done manually for each model though.

I also recommend looking into Onnx.jl which also aims at being framework agnostic. I think it supports more ops today compared to ONNXNaiveNASflux.