Struct rcudnn::Cudnn

source ·
pub struct Cudnn { /* private fields */ }
Expand description

Provides a the high-level interface to CUDA’s cuDNN.

Implementations§

source§

impl Cudnn

source

pub fn new() -> Result<Cudnn, Error>

Initializes a new CUDA cuDNN context.

Make sure your current CUDA device is cuDNN enabled.

source

pub fn from_c(id: cudnnHandle_t) -> Cudnn

Initializes a new CUDA cuDNN Context from its C type.

source

pub fn id_c(&self) -> &cudnnHandle_t

Returns the CUDA cuDNN Context as its C type.

source

pub fn version() -> usize

Returns the version of the CUDA cuDNN library.

source

pub fn init_convolution( &self, src_desc: &TensorDescriptor, conv_desc: ConvolutionDescriptor, filter_desc: FilterDescriptor, dest_desc: &TensorDescriptor ) -> Result<ConvolutionConfig, Error>

Initializes the parameters and configurations for running CUDA cuDNN convolution operations.

This includes finding the right convolution algorithm, workspace size and allocating that workspace.

source

pub fn init_normalization( &self, lrn_n: u32, lrn_alpha: f64, lrn_beta: f64, lrn_k: f64 ) -> Result<NormalizationConfig, Error>

Initializes the parameters and configurations for running CUDA cuDNN LRN operations.

source

pub fn init_pooling( &self, window: &[i32], padding: &[i32], stride: &[i32] ) -> Result<PoolingConfig, Error>

Initializes the parameters and configurations for running CUDA cuDNN Pooling operations.

source

pub fn init_activation(&self) -> Result<ActivationConfig, Error>

Initializes the parameters and configurations for running CUDA cuDNN Activation operations.

source

pub fn init_dropout( &self, probability: f32, seed: u64 ) -> Result<DropoutConfig, Error>

Initializes the parameters and configurations for running CUDA cuDNN dropout operation.

source

pub fn init_rnn( &self, x_desc: &[TensorDescriptor], rnn_desc: RnnDescriptor, hidden_size: i32, num_layers: i32, seq_length: i32, dropout_memory: cudnnDropoutDescriptor_t, input_mode: cudnnRNNInputMode_t, direction_mode: cudnnDirectionMode_t, network_mode: cudnnRNNMode_t, algorithm: cudnnRNNAlgo_t, data_type: DataType, math_type: cudnnMathType_t ) -> Result<RnnConfig, Error>

Initialize RNN

source

pub fn rnn_forward<T>( &self, rnn_config: &RnnConfig, src_desc: Vec<TensorDescriptor>, src: *const c_void, output_desc: Vec<TensorDescriptor>, output: *mut c_void, hidden_desc: &TensorDescriptor, hidden: *const c_void, cell_desc: &TensorDescriptor, cell: *const c_void, weight_desc: &FilterDescriptor, weight: *const c_void, hidden_output_desc: &TensorDescriptor, hidden_output: *mut c_void, cell_output_desc: &TensorDescriptor, cell_output: *mut c_void, workspace: *mut c_void, reserve_data: *mut c_void ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Train & Return Results for RNN

source

pub fn rnn_backward_data<T>( &self, rnn_config: &RnnConfig, output_desc: Vec<TensorDescriptor>, output: *const c_void, output_gradient_desc: Vec<TensorDescriptor>, output_gradient: *const c_void, hidden_gradient_desc: &TensorDescriptor, hidden_gradient: *const c_void, cell_gradient_desc: &TensorDescriptor, cell_gradient: *const c_void, weight_desc: &FilterDescriptor, weight: *const c_void, hidden_desc: &TensorDescriptor, hidden: *const c_void, cell_desc: &TensorDescriptor, cell: *const c_void, input_gradient_desc: Vec<TensorDescriptor>, input_gradient: *mut c_void, input_hidden_gradient_desc: &TensorDescriptor, input_hidden_gradient: *mut c_void, input_cell_gradient_desc: &TensorDescriptor, input_cell_gradient: *mut c_void, workspace: *mut c_void, reserve_data: *mut c_void ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Train & Return Results for RNN

source

pub fn rnn_backward_weights<T>( &self, rnn_config: &RnnConfig, src_desc: Vec<TensorDescriptor>, src: *const c_void, hidden_desc: &TensorDescriptor, hidden: *const c_void, output_desc: Vec<TensorDescriptor>, output: *const c_void, weight_desc: FilterDescriptor, weight: *mut c_void, workspace: *mut c_void, reserve_data: *mut c_void ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Train & Return Results for RNN

source

pub fn sigmoid_forward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward Sigmoid Activation function.

Writes the result of the computation to dest_data.

source

pub fn sigmoid_backward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Sigmoid Activation function.

Writes the result of the computation to dest_diff_data.

source

pub fn relu_forward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward Rectified Linear Activation function.

Writes the result of the computation to dest_data.

source

pub fn relu_backward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Rectified Linear Activation function.

Writes the result of the computation to dest_diff_data.

source

pub fn tanh_forward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward Hyperbolic Tangent Activation function.

Writes the result of the computation to dest_data.

source

pub fn tanh_backward<T>( &self, activation_conf: &ActivationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Hyperbolic Tangent Activation function.

Writes the result of the computation to dest_diff_data.

source

pub fn convolution_forward<T>( &self, conv_config: &ConvolutionConfig, workspace: *mut c_void, filter_data: *const c_void, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward Convolution function.

Writes the result of the computation to dest_data.

source

pub fn convolution_backward_bias<T>( &self, dest_grad_desc: &TensorDescriptor, dest_grad_data: *const c_void, bias_grad_desc: &TensorDescriptor, bias_grad_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Convolution function w.r.t the bias.

Writes the result of the computation to bias_grad_data.

source

pub fn convolution_backward_filter<T>( &self, conv_config: &ConvolutionConfig, workspace: *mut c_void, src_desc: &TensorDescriptor, src_data: *const c_void, dest_grad_desc: &TensorDescriptor, dest_grad_data: *const c_void, filter_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Convolution function w.r.t the filter.

Writes the result of the computation to filter_data.

source

pub fn convolution_backward_data<T>( &self, conv_config: &ConvolutionConfig, workspace: *mut c_void, filter_data: *const c_void, dest_grad_desc: &TensorDescriptor, dest_grad_data: *const c_void, src_grad_desc: &TensorDescriptor, src_grad_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward Convolution function w.r.t the data.

Writes the result of the computation to src_grad_data.

source

pub fn softmax_forward<T>( &self, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward softmax function.

Writes the result of the computation to dest_data.

source

pub fn softmax_backward<T>( &self, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward softmax function.

Writes the result of the computation to dest_diff_data.

source

pub fn log_softmax_forward<T>( &self, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward logarithmic softmax function.

Writes the result of the computation to dest_data.

source

pub fn log_softmax_backward<T>( &self, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward logarithmic softmax function.

Writes the result of the computation to dest_diff_data.

source

pub fn lrn_forward<T>( &self, normalization_conf: &NormalizationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward local response normalization function.

Writes the result of the computation to dest_data.

source

pub fn lrn_backward<T>( &self, normalization_conf: &NormalizationConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward local response normalization function.

Writes the result of the computation to dest_diff_data.

source

pub fn pooling_avg_forward<T>( &self, pooling_conf: &PoolingConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward average pooling function.

Writes the result of the computation to dest_data.

source

pub fn pooling_avg_backward<T>( &self, pooling_conf: &PoolingConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward average pooling function.

Writes the result of the computation to dest_diff_data.

source

pub fn pooling_max_forward<T>( &self, pooling_conf: &PoolingConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the forward max pooling function.

Writes the result of the computation to dest_data.

source

pub fn pooling_max_backward<T>( &self, pooling_conf: &PoolingConfig, src_desc: &TensorDescriptor, src_data: *const c_void, src_diff_desc: &TensorDescriptor, src_diff_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *const c_void, dest_diff_desc: &TensorDescriptor, dest_diff_data: *mut c_void, scale: ScalParams<T> ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes the backward max pooling function.

Writes the result of the computation to dest_diff_data.

source

pub fn dropout_forward<T>( &self, dropout_conf: &DropoutConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes probability and applies it to Dropout

Writes the result of the computation to dest_data

source

pub fn dropout_backward<T>( &self, dropout_conf: &DropoutConfig, src_desc: &TensorDescriptor, src_data: *const c_void, dest_desc: &TensorDescriptor, dest_data: *mut c_void ) -> Result<(), Error>
where T: Float + DataTypeInfo,

Computes probability and applies it to Dropout

Writes the result of the computation to dest_data

Trait Implementations§

source§

impl Clone for Cudnn

source§

fn clone(&self) -> Cudnn

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Cudnn

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Cudnn

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Sync for Cudnn

Auto Trait Implementations§

§

impl RefUnwindSafe for Cudnn

§

impl !Send for Cudnn

§

impl Unpin for Cudnn

§

impl UnwindSafe for Cudnn

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.