Is there a way to export a pytorch model to pure C code ?
Can you use torch.export() to go from Export IR to LLVM/MLIR IR to pure C, maybe using EmitC ?
My alternative approach is to export my model to ONNX, then load into Tinygrad, then compile to C code, which TinyGrad does anyway as it is essentially a compiler. However i would have thought that pytorch could do this natively with torch.export().
Motivation is to create a self contained C library without any dependencies on executorch or onnxruntime.
Direct C code export isn’t supported but torch.export plus AOTInductor can produce a self contained C compatible library without python or onnx dependencies.
@Peter_Featherstone we’re building this exact thing at Muna. We ingest plain Python/PyTorch code, transpile it to C++, then cross-compile it for different platforms. The compiled binaries are fully self-contained, hardware accelerated, and can be used from multiple languages in as little as two lines of code.
Hop on our Slack and I’ll be happy to give you a walkthrough.