2 unstable releases

✓ Uses Rust 2018 edition

0.2.0 Mar 16, 2020
0.1.0 Jul 21, 2019

#29 in Machine learning

23 downloads per month


1.5K SLoC

OpenCL-accelerated 2D convolutions for Rust

Travis Build Status License: Apache-2.0 rust 1.39.0+ required

Documentation: crate docs (master)

This library provides 2D convolutions accelerated with OpenCL. Convolutions are particularly useful for deep learning tasks, such as image recognition; they are a basic building block for convolutional neural networks.

The library is intended mostly for quick-and-dirty hacking in deep learning research, in which one needs a separate spatial convolution primitive. Note that full-scale DL frameworks (TensorFlow, PyTorch, etc.) will most probably be a more robust and scalable tool for more high-level tasks.


See crate docs for the examples of usage.

Installing OpenCL

OpenCL has a variety of implementations. For quick testing, one may use POCL; it is open source and not tied to hardware (at the cost of being CPU-based, i.e., orders of magnitude slower than OpenCL implementations by GPU vendors). POCL may be installed from sources with the commands like these (showcased here for Ubuntu Bionic):

# Install utils for build
apt-get install build-essential cmake pkg-config libhwloc-dev zlib1g-dev
# Install OpenCL-related utils
apt-get install ocl-icd-libopencl1 ocl-icd-dev ocl-icd-opencl-dev clinfo
# Install LLVM / Clang from the official APT repository
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 
add-apt-repository 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
apt-get update
apt-get install clang-9 libclang-9-dev llvm-9 llvm-9-dev

# Get POCL sources
export POCL_VER=1.4 # latest stable version
curl -sSL "https://github.com/pocl/pocl/archive/v$POCL_VER.tar.gz" > pocl-$POCL_VER.tar.gz
tar xf "pocl-$POCL_VER.tar.gz"
# Build POCL from the sources
cd pocl-$POCL_VER
mkdir build && cd build
cmake -DWITH_LLVM_CONFIG=/usr/bin/llvm-config-9 -DCMAKE_INSTALL_PREFIX=/usr ..

# Verify installation
# If successful, `clinfo` should display information about the POCL platform.


Licensed under the Apache 2.0 license.


~53K SLoC