模块化通用稀疏工作空间的编译
Compilation of Modular and General Sparse Workspaces
AI总结:
本文提出可自动检测稀疏散射并插入模块化稀疏工作空间的编译器,在性能与内存上兼顾稀疏和稠密方案,并可泛化到任意张量表达式。
摘要:
近年来,关于编译稀疏张量代数表达式的研究大量涌现。本文解决了这些工作中的一个不足,即如何生成在时间和空间上都高效的代码,将值散射到稀疏结果张量中。我们通过一种编译器设计来解决该不足:该设计生成的代码使用稀疏中间张量(稀疏工作空间),作为执行散射的计算代码与不支持随机插入的结果张量之间的高效适配器。我们的编译器会自动检测张量表达式中的稀疏散射行为,并插入必要的中间工作空间张量。我们提出了一种用于工作空间插入的算法模板,它是代码生成算法的主干。该算法模板在设计上是模块化的,支持跨越多种用户自定义实现的稀疏工作空间。评估表明,稀疏工作空间相比先前工作中的稠密工作空间,速度最高可快27.12倍。另一方面,在其他情形下,稠密工作空间相比本编译器生成的稀疏工作空间速度最高可快7.58倍,这促使我们采用同时支持两者的编译器设计。本编译器生成的串行代码在其所支持的表达式上,可与手工优化的线性代数和张量代数库相竞争,同时又能推广到任意其他表达式。稀疏工作空间还因压缩掉零值而比稠密工作空间更具内存效率。这种压缩能够渐近降低内存使用,使原本会耗尽内存的数据上的张量计算成为可能。
英文摘要:
Recent years have seen considerable work on compiling sparse tensor algebra expressions. This paper addresses a shortcoming in that work, namely how to generate efficient code (in time and space) that scatters values into a sparse result tensor. We address this shortcoming through a compiler design that generates code that uses sparse intermediate tensors (sparse workspaces) as efficient adapters between compute code that scatters and result tensors that do not support random insertion. Our compiler automatically detects sparse scattering behavior in tensor expressions and inserts necessary intermediate workspace tensors. We present an algorithm template for workspace insertion that is the backbone of our code generation algorithm. Our algorithm template is modular by design, supporting sparse workspaces that span multiple user-defined implementations. Our evaluation shows that sparse workspaces can be up to 27.12$\times$ faster than the dense workspaces of prior work. On the other hand, dense workspaces can be up to 7.58$\times$ faster than the sparse workspaces generated by our compiler in other situations, which motivates our compiler design that supports both. Our compiler produces sequential code that is competitive with hand-optimized linear and tensor algebra libraries on the expressions they support, but that generalizes to any other expression. Sparse workspaces are also more memory efficient than dense workspaces as they compress away zeros. This compression can asymptotically decrease memory usage, enabling tensor computations on data that would otherwise run out of memory.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。