Skip to main content
QUICK REVIEW

[论文解读] Sionnx: Automatic Unit Test Generator for ONNX Conformance

Xinli Cai, Peng Zhou|arXiv (Cornell University)|Jun 12, 2019
Adversarial Robustness in Machine Learning参考文献 22被引用 5
一句话总结

Sionnx 是首个针对 ONNX 兼容性测试的自动单元测试生成工具,采用一种新型的算子规范语言(OSL)和三阶段随机化策略(TDBc-gen),通过系统性地探索数据类型、维度和边界条件,生成高覆盖率的测试用例。它实现了在 ONNX 框架中可扩展、准确且高效的兼容性测试,同时最大限度减少人工干预。

ABSTRACT

Open Neural Network Exchange (ONNX) is an open format to represent AI models and is supported by many machine learning frameworks. While ONNX defines unified and portable computation operators across various frameworks, the conformance tests for those operators are insufficient, which makes it difficult to verify if an operator's behavior in an ONNX backend implementation complies with the ONNX standard. In this paper, we present the first automatic unit test generator named Sionnx for verifying the compliance of ONNX implementation. First, we propose a compact yet complete set of rules to describe the operator's attributes and the properties of its operands. Second, we design an Operator Specification Language (OSL) to provide a high-level description for the operator's syntax. Finally, through this easy-to-use specification language, we are able to build a full testing specification which leverages LLVM TableGen to automatically generate unit tests for ONNX operators with much large coverage. Sionnx is lightweight and flexible to support cross-framework verification. The Sionnx framework is open-sourced in the github repository (https://github.com/alibaba/Sionnx).

研究动机与目标

  • 解决由于依赖手工编写测试用例而导致 ONNX 算子缺乏全面自动化兼容性测试的问题。
  • 减少为 ONNX 算子(尤其是计算密集型算子如 LSTM)编写复杂参考算法的手动负担。
  • 设计一个轻量、灵活的框架,支持 ONNX 算子实现的跨框架验证。
  • 通过聚焦于具有行为意义的测试点(如数据类型组合、维度变化和边界条件),以最少的测试用例实现高测试覆盖率。

提出的方法

  • 提出一种紧凑的基于规则的系统,用于描述算子属性和操作数约束,从而精确指定有效输入。
  • 引入算子规范语言(OSL),一种高层级、人类可读的语言,用于描述 ONNX 算子的语法和语义。
  • 利用 LLVM TableGen 将 OSL 规范编译为可执行的测试生成代码。
  • 设计一种三阶段随机化策略(TDBc-gen),确保覆盖数据类型组合、数据维度和边界条件。
  • 采用加权采样方法,将测试用例均匀分布于各类数据类型组合和维度范围,以最大化覆盖率。
  • 通过重用现有的基于 Numpy 的算法生成参考结果,减少对自定义实现的需求。

实验结果

研究问题

  • RQ1如何实现 ONNX 兼容性测试的自动化,以减少对手工编写测试用例的依赖?
  • RQ2何种系统化方法可在最小化测试用例数量的同时确保高覆盖率?
  • RQ3如何可靠且高效地生成复杂 ONNX 算子的参考结果?
  • RQ4哪些最关键的输入变化(如数据类型、维度、边界值)会触发算子的不同行为?
  • RQ5能否设计一种既灵活又可复用于多个 ONNX 框架的规范语言和随机化策略?

主要发现

  • Sionnx 成功采用轻量级、基于规则的方法,生成覆盖全部数据类型、维度和边界条件的单元测试。
  • TDBc-gen 随机化策略确保了所有类型组合和维度范围中测试用例的均匀分布,提升了测试多样性。
  • 该框架通过重用现有的基于 Numpy 的实现,显著减少了手动实现参考算法的需求。
  • Sionnx 支持两种测试配置——'smoke' 和 'full'——可针对操作数或同时针对操作数与属性进行针对性测试。
  • 该系统已开源,并与 LLVM TableGen 集成,可无缝集成到现有的 ONNX 测试工作流中。
  • 评估结果表明,Sionnx 生成的测试用例在覆盖率上显著优于传统手工编写的测试集,尤其在边界情况和复杂算子方面表现突出。

更好的研究,从现在开始

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

无需绑定信用卡

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