计算机科学 ›› 2026, Vol. 53 ›› Issue (6): 128-136.doi: 10.11896/jsjkx.250600137
王一品1, 蔡成欢1, 许嘉滨2, 周学功3, 张逢喆3, 曹伟3, 张帆3, 余新胜4
WANG Yipin1, CAI Chenghuan1, XU Jiabin2, ZHOU Xuegong3, ZHANG Fengzhe3, CAO Wei3, ZHANG Fan3, YU Xinsheng4
摘要: 随着人工智能的快速发展,基于 RISC-V 指令扩展的神经网络加速器成为研究热点。深度学习编译器是实现神经网络模型在硬件平台上高效部署的关键。然而,结合硬件特性修改现有编译器的调优规则对开发人员要求较高,同时现有编译器缺乏对专门转置硬件单元的编译支持,无法通过数据流重构实现高效转置,导致未充分发挥此类硬件的性能潜力。针对这些问题,首先,基于 MLIR 框架设计了一款面向 RISC-V 神经网络专用加速器的编译工具链,可实现模型端到端的部署;其次,在 MLIR 框架中引入了硬件特征相关的 Dialect,编译器能够结合加速器缓冲区大小、脉动阵列尺寸、双缓冲策略以及数据流模式优化分块矩阵乘法操作,并结合硬件结构,通过改变矩阵数据流的方式实现矩阵转置操作,避免大规模数据的交换。此外,还根据脉动阵列特性实现了卷积算子融合以及矩阵乘法与向量计算的算子融合。实验结果表明,转置优化后运行速度平均提升了14.55倍,算子融合后运行速度平均提升了 41.59%,综合优化后 BERT 模型运行速度平均提升了 5.13%。
中图分类号:
| [1]WANG Y,WANG Y,LI H,et al.Systolic cube:A spatial 3D CNN accelerator architecture for low power video analysis[C]//Proceedings of the 56th Annual Design Automation Conference 2019.2019:1-6. [2]PATWARDHAN N,MARRONE S,SANSONE C.Transfor-mers in the real world:A survey on nlp applications[J].Information,2023,14(4):242. [3]PAREKH D,PODDAR N,RAJPURKAR A,et al.A review on autonomous vehicles:Progress,methods and challenges[J].Electronics,2022,11(14):2162. [4]MEZGER B W,SANTOS D A,DILILLO L,et al.A survey of the RISC-V architecture software support[J].IEEE Access,2022,10:51394-51411. [5]CUI E,LI T,WEI Q.Risc-v instruction set architecture extensions:A survey[J].IEEE Access,2023,11:24696-24711. [6]GENC H,KIM S,AMID A,et al.Gemmini:Enabling systematic deep-learning architecture evaluation via full-stack integration[C]//2021 58th ACM/IEEE Design Automation Conference (DAC).IEEE,2021:769-774. [7]LI M,LIU Y,LIU X,et al.The deep learning compiler:A comprehensive survey[J].IEEE Transactions on Parallel and Distributed Systems,2020,32(3):708-727. [8]ZHANG H,XING M,WU Y,et al.Compiler Technologies in Deep Learning Co-Design:A Survey[J].Intelligent Computing,2023,2:40. [9]PECCIA F N,BRINGMANN O.Integration of a systolic array based hardware accelerator into a DNN operator auto-tuning framework[C]//Proceedings of the 2023 Workshop onCompi-lers,Deployment,and Tooling for Edge AI.2023:21-26. [10]AHMADIFARSANI S,MUELLER-GRITSCHNEDER D,SCHLICHTMANN U.A High-Level Compiler Integration Approach for Deep Learning Accelerators Supporting Abstraction and Optimization[J].arXiv:2507.04828,2025. [11]GitHub.An MLIR-based compiler framework bridges DSLs(domain-specific languages) to DSAs (domain-specific architectures)[DB/OL].https://github.com/buddy-compiler/buddy-mlir. [12]ROTEM N,FIX J,ABDULRASOOL S,et al.Glow:Graph lowering compiler techniques for neural networks[J].arXiv:1805.00907,2018. [13]ZHENG L,JIA C,SUN M,et al.Ansor:Generating {High-Performance} tensor programs for deep learning[C]//14th USENIX Symposium on Operating Systems Design and Implementation (OSDI 20).2020:863-879. [14]ZHENG B,JIANG Z,YU C H,et al.DietCode:Automatic optimization for dynamic tensor programs[J].Proceedings of Machine Learning and Systems,2022,4:848-863. [15]EKLUNDH J O.Efficient matrix transposition[J].Two-Dimensional Digital Signal Prcessing II:Transforms and Median Filters,2006,43:9-35. [16]FRIGO M,LEISERSON C E,PROKOP H,et al.Cache-oblivious algorithms[J].ACM Transactions on Algorithms,2012,8(1):1-22. [17]RUETSCH G,MICIKEVICIUS P.Optimizing matrix transpose in CUDA[C]//NVIDIA Technical Report.2009:1-24. [18]GOMEZ-LUNA J,SUNG I J,CHANG L W,et al.In-place matrix transposition on GPUs[J].IEEE Transactions on Parallel and Distributed Systems,2015,27(3):776-788. [19]VASILACHE N,ZINENKO O,THEODORIDIS T,et al.Tensor comprehensions:Framework-agnostic high-performance machine learning abstractions[J].arXiv:1802.04730,2018. [20]BADER M,ZENGER C.Cache oblivious matrix multiplication using an element ordering based on a Peano curve[J].Linear Algebra and Its Applications,2006,417(2/3):301-313. [21]FRIGO M,LEISERSON C E,PROKOP H,et al.Cache-oblivious algorithms[C]//40th Annual Symposium on Foundations of Computer Science (Cat.No.99CB37039).IEEE,1999:285-297. [22]TORRES L A,BARRIOS C J,DENNEULIN Y.Evaluation of Computational and Power Performance in Matrix Multiplication[C]//High Performance Computing:11th Latin American High Performance Computing Conference.2024. [23]ADEFEMI T.Analysis of the Performance of the Matrix Multiplication Algorithm on the Cirrus Supercomputer[J].arXiv:2408.15384,2024. [24]NIU W,GUAN J,WANG Y,et al.Dnnfusion:accelerating deep neural networks execution with advanced operator fusion[C]//Proceedings of the 42nd ACM SIGPLAN International Confe-rence on Programming Language Design and Implementation.2021:883-898. [25]ZHAO J,GAO X,XIA R,et al.Apollo:Automatic partition-based operator fusion through layer by layer optimization[J].Proceedings of Machine Learning and Systems,2022,4:1-19. [26]GENC H,KIM S,AMID A,et al.Gemmini Tutorial:Generate Custom DNN Accelerators with Full-System Full-Stack Evaluation [C]//Proceedings of the Conference on Machine Learning and Systems (MLSys).2022. |
|
||