Frontiers of Data and Domputing ›› 2022, Vol. 4 ›› Issue (3): 19-29.

CSTR: 32002.14.jfdc.CN10-1649/TP.2022.03.002

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

• Special Issue: Advanced Intelligent Computing Platform and Application • Previous Articles     Next Articles

Implementation of Element-Wise Operator in TensorFlow Framework Based on OpenCL

SUI Yicheng1(),SHI Changqing1(),SUN Yufei1,2,*(),ZHANG Yuzhi1,2(),CHEN Yuqiao1(),ZHANG Yuzhe1()   

  1. 1. College of software, Nankai University, Tianjin 300350, China
    2. Haihe Lab of ITAI, Tianjin 300350, China
  • Received:2022-03-04 Online:2022-06-20 Published:2022-06-20
  • Contact: SUN Yufei;;;;;


[Objective] Deep learning models are widely used in various typical artificial intelligence fields with strong modeling performance and excellent multi-scene adaptability. At present, heterogeneous parallel computing technology is usually used to meet the computing power requirements of deep learning models. However, current deep learning frameworks generally use programming models such as CUDA or ROCm, which can only support equipment of specific manufacturers. It is necessary to support general heterogeneous computing equipment by the OpenCL programming standard. So we focused on implementing the OpenCL version of the TensorFlow framework. [Methods] This paper analyzes the code of the Element-Wise operator implemented mainly based on the interface provided by the Eigen library in the TensorFlow framework, disassembles the encapsulation method of the corresponding structure and class, and implements the Element-Wise operator based on the OpenCL programming standard. Implementation and encapsulation ensure the specification and extensibility of the code. [Results] This paper tests and compares the Element-Wise operator of OpenCL with the CUDA operator. The experimental results verify the feasibility of the implementation of the operator with OpenCL in terms of correctness and computational efficiency. [Conclusions] As an essential part of implementing the TensorFlow framework with OpenCL, the work presented in paper successfully implement the OpenCL version of the Element-Wise operator in the TensorFlow framework. The computational accuracy and calculation efficiency of the operator implemented in this paper is also verified by experiments.

Key words: OpenCL, TensorFlow, Kernel Function