将训练好的Keras模型自动生成可独立运行的C++代码,提升物理模拟计算效率。
CodeJeNN: A simple C++ neural network generator for physics applications

- 通过Keras模型直接生成无外部依赖的C++推理代码
- 在流体仿真中实现加速且精度不下降
- 适合需要高性能集成的物理仿真开发人员
机器学习在物理数值方法中已展现提速潜力,但将基于Python的库集成到高性能C++求解器中会产生性能瓶颈。我们提出CodeJeNN,通过从训练好的Keras模型自动生成可独立运行的C++代码,消除外部依赖,仅通过少量内联函数实现无缝集成。本文介绍了Keras到C++的转换流程、支持的架构及局限性。通过与Keras在急切模式和JIT模式下的推理基准对比,以及氢-空气混合层粘性建模的计算流体力学(CFD)测试案例,验证了CodeJeNN在不损失精度的前提下实现速度提升。
原文摘要 · Abstract (English)
Machine learning has shown speedups for numerical methods in physics applications, but integrating Python-based libraries into high-performance C++ solvers creates performance bottlenecks. We present CodeJeNN, which bridges this gap by auto-generating self-contained C++ code from trained Keras models for inference. This eliminates external dependencies through minimal inlined functions, allowing seamless integration into existing frameworks. We describe the Keras-to-C++ workflow, supported architectures, and limitations. CodeJeNN is demonstrated through inference benchmarks against Keras in eager and JIT modes and a CFD test case modeling viscosity in a hydrogen-air mixing layer, showing speedups without sacrificing accuracy.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。