cudnn 1.2.1

safe Rust wrapper for CUDA's cuDNN
Documentation

Provides a safe and convenient wrapper for the CUDA cuDNN API.

This crate (1.0.0) was developed against cuDNN v3.

Architecture

This crate provides three levels of entrace.

FFI The ffi module exposes the foreign function interface and cuDNN specific types. Usually, there should be no use to touch it if you only want to use cuDNN in you application. The ffi is provided by the rust-cudnn-sys crate and gets reexported here.

Low-Level The api module exposes already a complete and safe wrapper for the cuDNN API, including proper Rust Errors. Usually there should be not need to use the API directly though, as the Cudnn module, as described in the next block, provides all the API functionality but provides a more convenient interface.

High-Level The cudnn module exposes the Cudnn struct, which provides a very convenient, easy-to-understand interface for the cuDNN API. There should be not much need to obtain and read the cuDNN manual. Initialize the Cudnn struct and you can call the available methods wich are representing all the available cuDNN operations.

Examples

extern crate cudnn;
extern crate libc;
use cudnn::{Cudnn, TensorDescriptor};
use cudnn::utils::{ScalParams, DataType};
fn main() {
    // Initialize a new cuDNN context and allocates resources.
    let cudnn = Cudnn::new().unwrap();
    // Create a cuDNN Tensor Descriptor for `src` and `dest` memory.
    let src_desc = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap();
    let dest_desc = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap();
    // Obtain the `src` and memory pointer on the GPU.
    // NOTE: You wouldn't do it like that. You need to really allocate memory on the GPU with e.g. CUDA or Collenchyma.
    let src_data: *const ::libc::c_void = ::std::ptr::null();
    let dest_data: *mut ::libc::c_void = ::std::ptr::null_mut();
    // Now you can compute the forward sigmoid activation on your GPU.
    cudnn.sigmoid_forward::<f32>(&src_desc, src_data, &dest_desc, dest_data, ScalParams::default());
}

Notes

rust-cudnn was developed at Autumn for the Rust Machine Intelligence Framework Leaf.

rust-cudnn is part of the High-Performance Computation Framework Collenchyma, for the Neural Network Plugin. For an easy, unified interface for NN operations, such as those provided by cuDNN, you might check out Collenchyma.