| name | snn-mlir-neuromorphic-compilation |
| description | SNN-MLIR编译方法论 — MLIR方言用于将神经形态SNN从NIR编译到裸机C代码。支持浮点和量化数据,自动重缩放操作,生成依赖-free C11代码。 |
| platforms | ["linux","macos","windows"] |
| tags | ["snn","neuromorphic","compiler","mlir","nir","quantization"] |
SNN-MLIR: Neuromorphic SNN Compilation Bridge
核心创新
论文: SNN-MLIR: An MLIR Dialect for Compiling Neuromorphic SNNs from NIR to Bare-Metal C (arXiv:2606.09213v1)
作者: Alejandro García Gener, Alvaro Rollón de Pinedo
发布: 2026-06-08
关键贡献
- NIR-MLIR-C编译桥接: 实现从Neuromorphic Intermediate Representation到MLIR再到裸机C代码的完整编译流程
- 类型多态操作: 单一IR同时支持浮点(f32/f64)和量化数据,服务于模拟和硬件部署
- 自动重缩放: Python前端自动插入重缩放操作,保持量化尺度跨层一致性
- 依赖-free部署: 生成自包含C11代码,可在任何C-capable CPU或嵌入式目标编译运行
技术架构
编译流程
NIR文件 → Python前端 → SNN-MLIR IR → Lowering Pass → linalg/arith → C11代码 → CPU/嵌入式
核心操作
- 类型多态: 相同操作适用于浮点和整数数据类型
- 量化处理: 自动尺度调整和截断操作
- 标准Lowering: 转换为标准MLIR linalg和arith操作
应用场景
- 框架迁移: 从SnnTorch、Lava、Norse等框架导出到统一IR
- 硬件部署: 嵌入式设备、神经形态芯片部署
- 仿真验证: 浮点模式验证后再量化部署
实现细节
Python前端
import nir
import snn_mlir
model = nir.read("model.nir")
mlir_ir = snn_mlir.from_nir(model, quantize=True)
c_code = snn_mlir.compile(mlir_ir, target="c11")
C11代码生成
- 自包含、无外部依赖
- 支持CPU和嵌入式目标
- 数值保真度验证
评估结果
- 数值保真度: 对比参考输出验证准确性
- 可移植性: 跨CPU目标测试
- 量化代价: 量化vs浮点性能对比
当前范围
开源许可
Apache-2.0 license with LLVM-exception
GitHub: https://github.com/[repository]
Activation
关键词: snn-mlir, mlir dialect, neuromorphic compilation, nir, quantization, embedded deployment, c11 code generation
Pitfalls
- 当前仅支持前馈网络: 循环网络、卷积网络暂不支持
- 量化尺度自动调整: Python前端插入的重缩放操作可能影响数值精度
- 仅CPU后端: 神经形态硬件加速器后端尚未实现
References
- arXiv:2606.09213 - SNN-MLIR原论文
- NIR规范: Neuromorphic Intermediate Representation
- MLIR文档: Multi-Level Intermediate Representation