Tensor kernels in machine learning (ML) often correspond to pure mathematical expressions, making term rewriting an attractive strategy for optimization and mapping to specialized hardware accelerators. However, existing ML intermediate representations (IRs) tend to either be \textit{pure but high-level}, making low-level rewrites to hardware targets inexpressible, or \textit{low-level but impure}, hampering the use of term rewriting altogether. This paper introduces Glenside, a pure IR whose core abstraction -- the \textit{access pattern} -- enables low-level, layout-aware, hardware-centric program rewrites. We demonstrate how term rewriting in Glenside can be used to map program fragments to hardware accelerator invocations and automatically discover classic data layout transformations like \texttt{im2col}. Glenside establishes a new foundation for exploring further term rewriting techniques in optimizing low-level tensor programs.
翻译:机器学习( ML) 中的电锯内核往往与纯数学表达式相对应, 使得术语重写为优化和绘制专业硬件加速器的有吸引力的战略。 但是, 现有的 ML 中间表示器( IR) 往往要么是\ textit{ pure but high }, 使低层次重写到硬件目标无法表达, 要么是\ textit{ low- level but impure}, 阻碍术语重写。 本文引入了 Glenside, 一个纯的 IR, 其核心抽象性 -- \ textit{ access typed} -- 使得低级别、 版式、 硬件中心程序重写程序成为。 我们演示了如何在 Gleside 中重新写术语可以用来绘制程序碎片成硬件加速器, 并自动发现经典的数据布局转换, 如\ textt{ im2col} 。 Glenside 为探索新的术语重写技术以优化低层次的 Ex 。