TensorFlow™ for OpenCL™ using SYCL™

01 June 2016

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 have now upstreamed all our Eigen code to the 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.

Codeplay Software Ltd has published this article only as an opinion piece. Although every effort has been made to ensure the information contained in this post is accurate and reliable, Codeplay cannot and does not guarantee the accuracy, validity or completeness of this information. The information contained within this blog is provided "as is" without any representations or warranties, expressed or implied. Codeplay Sofware Ltd makes no representations or warranties in relation to the information in this post.
Luke Iwanski's Avatar

Luke Iwanski

Staff Software Engineer, Compute & Graphics