数据与计算发展前沿 ›› 2022, Vol. 4 ›› Issue (2): 17-28.

doi: 10.11871/jfdc.issn.2096-742X.2022.02.002

• 专刊:先进智能计算平台及应用 • 上一篇    下一篇

TensorFlow框架中OpenCL核函数的测试验证方案设计与实现

陈禹乔(),孙羽菲*(),程大果(),张玉志(),周建宇(),隋轶丞(),石昌青()   

  1. 南开大学,软件学院,天津 300350
  • 收稿日期:2022-02-16 出版日期:2022-04-20 发布日期:2022-04-30
  • 通讯作者: 孙羽菲
  • 作者简介:陈禹乔,南开大学,软件学院,硕士研究生,主要研究方向为深度学习框架移植与高性能计算。
    本文主要设计文章架构并参与方案设计与实施。
    CHEN Yuqiao is currently a master’s student in the College of Software at Nankai University, Tianjin, China. His research interests include Deep Learning Framework Transplantation and High-Performance Computing.
    In this paper, he is mainly responsible for the design of the paper architecture and participating in the methodology design and implementation.
    E-mail: ujoenk@mail.nankai.edu.cn|孙羽菲,南开大学,软件学院,特聘研究员,博士,主要研究方向为深度学习、异构计算、人工智能等。
    本文主要承担论文指导和修改工作。
    SUN Yufei, Ph.D, is a professor at Coll -ege of Software, Nankai University. Her re-search interests include Deep Learning, Heterogeneous Computing,Artificial Intelligence, etc.
    In this paper she is mainly responsible for the paper guidance and paper revision.
    E-mail: yufei_sun@sina.com|程大果,南开大学,软件学院,硕士研究生,研究方向为深度学习和高性能计算。
    本文中负责参与方案设计与实施。
    CHENG Daguo is a master’s student in College of Software at Nankai University. His research interests include Deep Learning and High-Performance Computing.
    In this paper, he is mainly responsible for participating in the methodology design and Implementation.
    E-mail: chengdaguo@mail.nankai.edu.cn|张玉志,南开大学,软件学院,讲席教授,院长。主要研究方向为人工智能、模式识别、自然语言处理等。
    本文主要承担文献调研及指导。
    ZHANG Yuzhi is the chair professor and the Dean of Software College at Na-nkai University. His research interests include Artificial Intell-igence, Pattern Recognition, Natural Language Processing, etc.
    In this paper he is mainly responsible for the related work investigation and guidance.
    E-mail: zyz@nankai.edu.cn|周建宇,南开大学,软件学院,讲师,博士,主要研究方向为算法设计与优化、统计机器学习等。
    本文主要承担文献调研及论文修改。
    ZHOU Jianyu is a lecturer at College of Software, Nankai University. His res-earch interests include algorithm design and optimization, stat-istical machine learning, etc.
    In this paper, he is mainly responsible for the related work investigation and paper revision.
    E-mail: jyzhou@nankai.edu.cn|隋轶丞,南开大学,软件学院,博士研究生,主要研究方向为人工智能。
    本文中负责参与方案设计与实施。
    SUI Yicheng is a Ph.D student in Co-llege of Software at Nankai University. His research interests include Artificial Intelligence.
    In this paper, he is mainly responsible for participating in the methodology design and implementation.
    E-mail: suiyicheng@mail.nankai.edu.cn|石昌青,南开大学,软件学院,硕士研究生,主要研究方向为深度学习与高性能计算。
    本文中负责参与方案设计与实施。
    SHI Changqing is a master’s student in College of Software at Nankai University. His research interests include Deep Lea-rning and High-Performance Computing.
    In this paper, he is mainly responsible for participating in the methodology design and implementation.
    E-mail: shichangqing@mail.nankai.edu.cn
  • 基金资助:
    国家重点研发计划(2021YFB0300104)

Design and Implementation of Testing and Verification Method for OpenCL Kernels in TensorFlow

CHEN Yuqiao(),SUN Yufei*(),CHENG Daguo(),ZHANG Yuzhi(),ZHOU Jianyu(),SUI Yicheng(),SHI Changqing()   

  1. College of Software, Nankai University, Tianjin 300350, China
  • Received:2022-02-16 Online:2022-04-20 Published:2022-04-30
  • Contact: SUN Yufei

摘要:

【目的】TensorFlow是人工智能领域最具代表性的深度学习框架。国产加速设备需要一个支持OpenCL的TensorFlow才能发挥其加速性能,为此需要将TensorFlow框架下的CUDA代码向OpenCL转换。如何验证OpenCL核函数的正确性,是研发任务面对的重要问题。【方法】基于TensorFlow动态链接库自定义算子和raw_ops测试接口,本文提出了一套OpenCL核函数的测试解决方案,包括自定义算子的源码设计规范、测试代码规范、代码审核方法和测试流程。【结果】本文实现了对135个OpenCL核函数代码的审核与测试,在各种数据类型及多种数据规模下进行了测试对比,完成了OpenCL核函数正确性的验证,及其与CUDA核函数的性能比较。【结论】本文为TensorFlow下OpenCL核函数的测试提供了可靠而有效的解决方案。

关键词: TensorFlow, CUDA, OpenCL, 代码审核, 代码测试

Abstract:

[Objective] TensorFlow is the most representative deep learning framework in the field of artificial intelligence. The domestic acceleration device needs a version of TensorFlow with OpenCL support to take advantage of its acceleration performance, for which the CUDA code in TensorFlow needs to be converted to OpenCL code. How to verify the correctness of the OpenCL kernels is an important problem in the development task. [Methods] Based on the TensorFlow raw ops test interface and TensorFlow custom op implemented by the dynamic link library, this paper proposes a test scheme for OpenCL kernels, including the source code design rules of the custom op, test code rules, code review methods, and test process. [Results] This paper implements the review and testing of 135 OpenCL kernel function codes, tests and compares them under various data types and data scales, and completes the verification of the correctness of the OpenCL kernels and their performance comparison with the CUDA kernels. [Conclusions] This paper provides a reliable and effective approach for testing OpenCL kernels based on TensorFlow.

Key words: TensorFlow, CUDA, OpenCL, code review, code testing