SNN-MLIR:一种用于将神经形态SNN从NIR编译到裸机C的MLIR方言
SNN-MLIR: An MLIR Dialect for Compiling Neuromorphic SNNs from NIR to Bare-Metal C
AI总结:
提出SNN-MLIR,一种MLIR方言,通过NIR-MLIR-C编译桥将神经形态SNN模型从框架无关的NIR格式编译为可移植的C代码,支持浮点和量化数据,实现从仿真到硬件部署的统一中间表示。
摘要:
脉冲神经网络(SNN)越来越多地在各种框架(SnnTorch、Lava、Norse等)中训练,每个框架都有自己的模型格式。神经形态中间表示(NIR)通过提供一种通用的、框架无关的格式来交换训练好的SNN模型,解决了碎片化问题。NIR解决了交换问题,但仅止于此。它提供了网络的描述,而非运行网络的路径。每个后端仍需自行实现部署,之间没有共享的、可转换的编译器表示。本文提出snn-mlir,一种用于SNN的树外MLIR方言,以及一个NIR-MLIR-C编译桥。该方言提供了一小组类型多态操作,这些操作在浮点(f32/f64)和量化数据上行为一致,因此单一的中间表示同时服务于仿真和面向硬件的部署。一个Python前端读取任何NIR文件并发出方言IR,自动插入重新缩放操作以保持各层量化尺度一致。一个参考降级过程将方言转换为标准的linalg和arith操作,工具链从中生成自包含、无依赖的C11代码,可在任何支持C的CPU或嵌入式目标上编译和运行。我们评估了数值精度与参考输出的匹配度、跨CPU目标的可移植性以及量化的代价。当前范围是前馈全连接网络,后端为CPU。snn-mlir以Apache-2.0许可证(含LLVM例外)开源发布,并已在GitHub上可用。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。