[论文解读] Glow: Graph Lowering Compiler Techniques for Neural Networks
Glow 是一个开源的机器学习编译器,通过多个中间表示阶段将神经网络图降低到目标异构硬件,实现目标无关的优化和后端特定代码生成。
This paper presents the design of Glow, a machine learning compiler for heterogeneous hardware. It is a pragmatic approach to compilation that enables the generation of highly optimized code for multiple targets. Glow lowers the traditional neural network dataflow graph into a two-phase strongly-typed intermediate representation. The high-level intermediate representation allows the optimizer to perform domain-specific optimizations. The lower-level instruction-based address-only intermediate representation allows the compiler to perform memory-related optimizations, such as instruction scheduling, static memory allocation and copy elimination. At the lowest level, the optimizer performs machine-specific code generation to take advantage of specialized hardware features. Glow features a lowering phase which enables the compiler to support a high number of input operators as well as a large number of hardware targets by eliminating the need to implement all operators on all targets. The lowering phase is designed to reduce the input space and allow new hardware backends to focus on a small number of linear algebra primitives.
研究动机与目标
- 由于摩尔定律的局限以及日益增长的 ML 计算需求,激发对领域专用编译的需求。
- 提出 Glow 作为一个可重新目标化的编译器,为多种硬件后端生成优化代码。
- 引入一个两阶段、强类型的中间表示,用于高层图优化和低层内存优化。
- 描述量化和性能分析方法,以在多样设备上实现高效的整数运算。
- 提出在多个加速器上执行图的运行时和分区机制。
提出的方法
- 引入一个两阶段、强类型的中间表示(高层数据流 IR 和低层仅地址 IR)。
- 将高层运算符降低为低层线性代数原语,以实现后端简化(节点降阶)。
- 应用与目标无关的优化,随后是针对目标的优化与代码生成(IRGen)。
- 实现带有 profile-guided 范围的量化,将浮点网络转换为 int8 表示。
- 使用 ClassGen 自动生成 IR 指令和节点类,以简化后端开发。
- 提供一个 CPU 后端,具有小型、目标无关的标准库和算子堆叠,以融合数据并行运算。
- 提供一个 Glow 运行时,能够在设备之间分区图,将子图加载到加速器上,并管理异步推理请求。
实验结果
研究问题
- RQ1一个面向神经网络的可重新目标化编译器如何高效地将高层图映射到多种硬件后端?
- RQ2多级 IR 与 lowering 在实现后端特定优化、又不重复运算符实现方面扮演什么角色?
- RQ3量化和基于剖面的技术在在多样设备上产生准确、有效整数计算方面有多有效?
- RQ4哪些运行时策略(分区、资源分配、设备管理)能够在给定模型上最好地利用多个加速器?
主要发现
- Glow 提供了一种可扩展的降低方法,通过针对此小集合的线性代数原语来实现,从而减少为每个后端实现所有运算符的需求。
- 两级 IR 设计使目标无关的优化与硬件特定代码生成成为可能,提升了后端的灵活性。
- 带有 profile-guided 范围的量化使转换为 int8 和整数计算岛成为可能,促进高效推理。
- 具有运算符堆叠和小型标准库的 CPU 后端实现了融合集成的内核并改善了内存局部性,在如 Resnet50 和 VGG19 的模型上得到演示。
- Glow 的运行时支持跨多个加速器的分区与执行,协调子图加载与异步推理。
- 评估在真实模型上将 Glow 与 TensorFlow 和 TVM 进行比较以评估性能,测试平台使用 Kaby Lake CPU。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。