TensorFlow™ for OpenCL™ using SYCL™

Posted on June 1, 2016 by Luke Iwanski.

This post contains out of date information and this section was added on 7th August 2019
 
Development continues on the SYCL implementation for TensorFlow and we continue to make progress on this integration.

- The SYCL implementation is currently maintainted on a separate branch here.
- Up to date instructions on how to use the SYCL implementation for TensorFlow are here.

This implementation uses Eigen and we are currently leading the effort to upstream all our Eigen code to the main branch. At this point only one Pull Request is remaining. Once this is accepted we will begin upstreaming the changes to the TensorFlow main branch.


Codeplay has started work on adding OpenCL support to TensorFlow using SYCL. TensorFlow is built on top of the Eigen C++ library for linear algebra. Because Eigen uses C++ extensively, we have used SYCL (which enables Eigen-style C++ metaprogramming) to offload parts of Eigen to OpenCL devices.

You can get the code here: https://bitbucket.org/benoitsteiner/opencl. This is open-source software and a work-in-progress, so not everything works yet (see below) but you are welcome to get involved.

To compile this code, you need a SYCL compiler. Currently, the only supported compiler is Codeplay's ComputeCpp, which is available currently via Codeplay's evaluation program. ComputeCpp will be made available for free as a public open beta, later in 2016 and then released with a free version (the ComputeCpp Community Edition) in 2017. This will let anyone compile and develop TensorFlow on OpenCL devices, such as AMD or Intel GPUs and CPUs. Alternatively, there is an open-source implementation of SYCL in development, called triSYCL, but it does not (yet) support the TensorFlow source code or compiling C++ for OpenCL devices (only CPUs using OpenMP). If you want open-source SYCL, you may want to get involved in that project, too.

There is a spreadsheet maintained here with a list of things left to do to fully support TensorFlow: https://docs.google.com/spreadsheets/d/1YbHn7dAFPPG_PgTtgCJlWhMGorUPYsF681TsZ4Y4LP0/edit#gid=0. As this is an open-source project, you are welcome to get involved.

Some of the acceleration of TensorFlow could use OpenCL C libraries directly, such as for the BLAS components, or convolutions. SYCL is being used for the C++ tensor operations only (for now) which enables complex programmability of those tensor operations.

The work on porting to SYCL is actually being performed in Eigen, so this will enable other software that uses Eigen to be accelerated on multiple heterogeneous devices. SYCL is designed to allow performance-portability, by enabling the writing of C++ generic algorithms that can adapt to the underlying hardware. Applying these techniques to Eigen will enable performance portability of a range of linear algebra operations. Some work on demonstrating performance-portability using SYCL has been presented here and also here.

If you are interested in paid internships at Codeplay to work more on Eigen or TensorFlow, there are positions open here.