将神经形态脉冲网络从NIR编译为可独立运行的C代码。
SNN-MLIR: An MLIR Dialect for Compiling Neuromorphic SNNs from NIR to Bare-Metal C

- 基于MLIR构建SNN中间表示,支持浮点与量化数据统一处理。
- 自动插入重缩放操作,确保量化精度在各层间一致。
- 生成无依赖的C11代码,可在任意嵌入式CPU上直接运行。
脉冲神经网络(SNN)在多个框架(如SnnTorch、Lava、Norse等)中训练,各自使用不同模型格式,造成碎片化。神经形态中间表示(NIR)提供了框架无关的模型交换格式,但仅解决模型描述问题,未提供部署路径。本文提出snn-mlir,一个非树形MLIR方言及NIR-MLIR-C编译桥。该方言采用类型多态操作,支持浮点(f32/f64)与量化数据,统一模拟与硬件部署。Python前端读取任意NIR文件,生成方言IR,并自动插入重缩放操作以保持层间量化尺度一致。参考降低转换将方言转为标准linalg与arith操作,工具链生成自包含、无依赖的C11代码,可在任何支持C的CPU或嵌入式目标上编译运行。评估包括数值保真度、跨CPU平台可移植性及量化开销。当前支持前馈全连接网络与CPU后端。snn-mlir以Apache-2.0许可证开源,已发布于Github。
原文摘要 · Abstract (English)
Spiking neural networks (SNNs) are increasingly trained in a wide range of frameworks (SnnTorch, Lava, Norse, and others) each with its own model format. The Neuromorphic Intermediate Representation (NIR) addresses this fragmentation by providing a common, framework-independent format for exchanging trained SNN models. NIR solves the exchange problem, but it stops there. It provides a description of a network, not a path to running one. Each backend is still left to implement deployment on its own, with no shared, transformable compiler representation in between. This paper presents snn-mlir, an outof-tree MLIR dialect for SNNs together with a NIR-MLIR-C compilation bridge. The dialect provides a small set of typepolymorphic operations that work identically on floating-point (f32/f64) and quantized data, so a single intermediate representation serves both simulation and hardware-oriented deployment. A Python front end reads any NIR file and emits dialect IR, automatically inserting rescaling operations to keep quantization scales consistent across layers. A reference lowering pass converts the dialect to standard linalg and arith operations, from which the toolchain produces self-contained, dependency free C11 code that compiles and runs on any C-capable CPU or embedded target. We evaluate numerical fidelity against reference outputs, portability across CPU targets, and the cost of quantization. The current scope is feedforward, fully-connected networks with a CPU backend. snn-mlir is released as open source under the Apache-2.0 license with LLVM-exception and it is already available on Github.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。