Is there a C/C++/Rust/Go library that can do inference on Flux models?

If not, is it useful to have one at least for simple layers like Dense, Conv, Scale, etc.?

Would building a C lib with PackageCompiler work?

Thanks. That looks interesting. Exploring.

Where can I find documentation for jl_ functions and types used in C? Thanks.

https://docs.julialang.org/en/v1/manual/embedding/

https://docs.julialang.org/en/v1/base/c/

Thank you. I did go through those sections. There are very useful examples of function usage, not really documentation. I guess I need to go through the header files.

I got a minimal example with Flux working though.

It seems like ONNX.jl is in the middle of some restructuring and is not currently supporting Flux.jl, but otherwise that could possibly be one way of moving a model to another language. Not sure what the exact status is, but does not seem to have too much activity recently :confused:

Thank you.

That just means you can’t import ONNX files as Flux models (check out GitHub - DrChainsaw/ONNXNaiveNASflux.jl: Import/export ONNX models if you must have that). Exporting to ONNX should work now for a decent number of models. I think the README could use some updating to reflect that, PRs welcome.

2 Likes

Thanks. If this can work with C/C++, it would be great.
The C-API route of running a jl environment is not ideal.

Once you’ve exported a model to ONNX, you can load it in the runtime of your choice. The most popular one is https://onnxruntime.ai/, which has C/C++ bindings. I know at least a few other runtimes should as well, but not exact names. ONNX | Supported Tools may be a good starting point to read further there.

3 Likes

Thank you.