Skip to main content
QUICK REVIEW

[论文解读] ShapeFlow: Dynamic Shape Interpreter for TensorFlow

Sahil Verma, Zhendong Su|arXiv (Cornell University)|Nov 26, 2020
Adversarial Robustness in Machine Learning参考文献 46被引用 7
一句话总结

ShapeFlow 是一个针对 TensorFlow 的动态抽象解释器,可在无需代码注解的情况下分析张量形状兼容性,其在 52 个深度学习基准测试中检测形状不兼容错误的平均速度提升了 499 倍,准确率达到 100%(仅一个误报),为机器学习开发者提供了实用且无需注解的调试解决方案。

ABSTRACT

We present ShapeFlow, a dynamic abstract interpreter for TensorFlow which quickly catches tensor shape incompatibility errors, one of the most common bugs in deep learning code. ShapeFlow shares the same APIs as TensorFlow but only captures and emits tensor shapes, its abstract domain. ShapeFlow constructs a custom shape computational graph, similar to the computational graph used by TensorFlow. ShapeFlow requires no code annotation or code modification by the programmer, and therefore is convenient to use. We evaluate ShapeFlow on 52 programs collected by prior empirical studies to show how fast and accurately it can catch shape incompatibility errors compared to TensorFlow. We use two baselines: a worst-case training dataset size and a more realistic dataset size. ShapeFlow detects shape incompatibility errors highly accurately -- with no false positives and a single false negative -- and highly efficiently -- with an average speed-up of 499X and 24X for the first and second baseline, respectively. We believe ShapeFlow is a practical tool that benefits machine learning developers. We will open-source ShapeFlow on GitHub to make it publicly available to both the developer and research communities.

研究动机与目标

  • 解决深度学习代码中形状不兼容错误频繁发生且检测成本高昂的问题,此类错误常导致崩溃并浪费计算资源。
  • 克服先前静态分析工具(如 Ariadne 和 Pythia)的局限性,这些工具需要手动代码注解,因此难以广泛使用。
  • 开发一种动态、轻量且精确的技术,在不修改原始代码或要求程序员注解的情况下,于执行过程中分析张量形状。
  • 在深度学习流水线早期阶段实现快速且精确的形状相关错误检测,以减少调试时间和计算资源浪费。
  • 提供一个实用的开源工具,可无缝集成到 TensorFlow 中,并在不增加开发者负担的前提下支持真实世界中的深度学习工作流。

提出的方法

  • ShapeFlow 实现了 TensorFlow API 的一种形状捕获变体,仅在执行过程中追踪张量形状,丢弃实际的张量值。
  • 它构建了一个类似于 TensorFlow 原始计算图的自定义形状计算图,从而支持动态形状分析。
  • 该工具以动态、基于解释的方式运行,从数据中推断输入张量的形状,并通过操作传播形状约束。
  • ShapeFlow 通过检查操作在执行过程中是否接收到违反其形状前置条件的输入来检测形状不兼容错误。
  • 它利用 Python 和 TensorFlow 的运行时环境执行程序而无需修改,确保兼容性和易用性。
  • 若所有形状约束均满足,系统返回“未检测到错误”消息;若发现不匹配,则崩溃并显示形状错误消息。

实验结果

研究问题

  • RQ1动态形状分析技术是否能比现有静态分析工具更高效、更准确地检测深度学习代码中的张量形状不兼容错误?
  • RQ2在不依赖代码注解或修改的前提下,形状分析工具在多大程度上可以实现快速且精确的检测?
  • RQ3与完整 TensorFlow 执行相比,动态形状解释器在速度和错误检测准确率方面表现如何?
  • RQ4在具有已知形状错误的真实世界深度学习程序上评估时,此类工具的误报率和漏报率是多少?
  • RQ5此类工具能否在不增加额外工程或维护负担的前提下被开发者实际采纳?

主要发现

  • ShapeFlow 在 52 个存在错误的程序中,对其中 51 个实现了 100% 的准确率检测形状不兼容错误,仅出现一次漏报。
  • 在所有修正版本的程序上,它均未产生任何误报,显示出极高的错误检测精度。
  • 在使用最坏情况的训练数据集大小时,ShapeFlow 相较于完整 TensorFlow 执行实现了平均 499 倍的速度提升。
  • 即使在更现实的数据集大小下,ShapeFlow 仍保持了相较于完整执行的平均 24 倍速度提升。
  • 该工具无需任何代码注解或修改,使其在真实世界使用中实用且对开发者友好。
  • 实现仅修改了数千个 TensorFlow API 中的 118 个,确保了未来支持的可维护性和可扩展性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。