OpenCL-accelerated 2D convolutions for Rust

Travis Build Status License: Apache-2.0 rust 1.34.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.

Usage

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 Xenial):

```bash

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/xenial/ llvm-toolchain-xenial-8 main' apt-get update apt-get install clang-8 libclang-8-dev llvm-8 llvm-8-dev

Get POCL sources

export POCLVER=1.3 # latest stable version curl -sSL "https://github.com/pocl/pocl/archive/v$POCLVER.tar.gz" > pocl-$POCLVER.tar.gz tar xf "pocl-$POCLVER.tar.gz"

Build POCL from the sources

cd pocl-$POCLVER mkdir build && cd build cmake -DWITHLLVMCONFIG=/usr/bin/llvm-config-8 -DCMAKEINSTALL_PREFIX=/usr .. make

Verify installation

clinfo

If successful, clinfo should display information about the POCL platform.

```

License

Licensed under the Apache 2.0 license.