Tenspiler:一种经验证的基于提升的张量运算编译器(扩展版)
Tenspiler: A Verified Lifting-Based Compiler for Tensor Operations (Extended Version)
AI总结:
针对张量处理基础设施遗留代码迁移成本高的问题,提出基于提升的验证编译器Tenspiler,通过中间语言TensIR将通用语言顺序程序转为张量运算,支持多后端,实现显著性能提升。
摘要:
张量处理基础设施(如深度学习框架与专用硬件加速器)已彻底改变了深度学习、图像处理等领域中计算密集型代码的执行与优化方式。这些基础设施在提供强大且富有表达力的抽象的同时,还能保障高性能。然而,要利用这些设施,代码必须专门采用这类软件框架或硬件加速器的API/指令集架构(ISA)编写。关键问题在于,鉴于这些领域的创新速度极快,随着新框架和加速器不断涌现,如今编写的代码很快就会沦为遗留代码,而手动迁移这类遗留代码需要耗费大量精力。\n为了让开发者在保留现有编程范式的同时能够利用这类领域特定语言(DSL),我们推出了Tenspiler——一种经验证的基于提升的编译器,它采用程序综合技术,将用通用编程语言(例如C++或Python代码)编写的顺序程序转换为张量运算。Tenspiler的核心是我们精心设计且简洁的中间语言,名为TensIR,用于表达张量运算。TensIR可实现高效的程序提升、验证与代码生成。\n目前,Tenspiler已支持6种DSL,覆盖了广泛的软件与硬件环境。此外,我们还证明,只需为TensIR添加简单的模式匹配规则,Tenspiler就能轻松支持新的后端。通过10个真实世界代码基准测试套件开展的实验评估表明,通过将代码转换后在6种不同的软件框架与硬件设备上执行,Tenspiler相较于相同基准测试的完全优化顺序实现,内核执行时间平均提升105倍,端到端执行时间平均提升9.65倍。
英文摘要:
Tensor processing infrastructures such as deep learning frameworks and specialized hardware accelerators have revolutionized how computationally intensive code from domains such as deep learning and image processing is executed and optimized. These infrastructures provide powerful and expressive abstractions while ensuring high performance. However, to utilize them, code must be written specifically using the APIs / ISAs of such software frameworks or hardware accelerators. Importantly, given the fast pace of innovation in these domains, code written today quickly becomes legacy as new frameworks and accelerators are developed, and migrating such legacy code manually is a considerable effort. To enable developers in leveraging such DSLs while preserving their current programming paradigm, we introduce Tenspiler, a verified lifting-based compiler that uses program synthesis to translate sequential programs written in general-purpose programming languages (e.g., C++ or Python code) into tensor operations. Central to Tenspiler is our carefully crafted yet simple intermediate language, named TensIR, that expresses tensor operations. TensIR enables efficient lifting, verification, and code generation. Currently, Tenspiler already supports $\textbf{six}$ DSLs, spanning a broad spectrum of software and hardware environments. Furthermore, we show that new backends can be easily supported by Tenspiler by adding simple pattern-matching rules for TensIR. Using 10 real-world code benchmark suites, our experimental evaluation shows that by translating code to be executed on $\textbf{6}$ different software frameworks and hardware devices, Tenspiler offers on average 105$\times$ kernel and 9.65$\times$ end-to-end execution time improvement over the fully-optimized sequential implementation of the same benchmarks.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。