pub fn rnn_backward_weights<T1, T2, L>(
        &self,
        rnn_desc: &RnnDescriptor<T1, T2>,
        add_grad: WGradMode,
        device_seq_lengths: &impl GpuBuffer<i32>,
        x_desc: &RnnDataDescriptor<T1, L>,
        x: &impl GpuBuffer<T1>,
        h_desc: &TensorDescriptor<T1, NCHW, 3>,
        hx: &impl GpuBuffer<T1>,
        y_desc: &RnnDataDescriptor<T1, L>,
        y: &impl GpuBuffer<T1>,
        dweight_space: &mut impl GpuBuffer<u8>,
        work_space: &mut impl GpuBuffer<u8>,
        reserve_space: &mut impl GpuBuffer<u8>,
    ) -> Result<(), CudnnError>
    where
        T1: DataType + RnnDataType,
        T2: DataType + SupportedPrec<T1>,
        L: RnnDataLayout,
        NCHW: SupportedType<T1>,
    {
        let device_sequence_lengths_ptr = device_seq_lengths.as_device_ptr().as_raw();

        let x_ptr = x.as_device_ptr().as_raw();
        let hx_ptr = x.as_device_ptr().as_raw();
        let y_ptr = y.as_device_ptr().as_raw();

        let dweight_space_ptr = dweight_space.as_device_ptr().as_raw_mut();
        let work_space_ptr = work_space.as_device_ptr().as_raw_mut();
        let reserve_space_ptr = reserve_space.as_device_ptr().as_raw_mut();

        unsafe {
            sys::cudnnRNNBackwardWeights_v8(
                self.raw,
                rnn_desc.raw,
                add_grad.into(),
                device_sequence_lengths_ptr,
                x_desc.raw,
                x_ptr as *const std::ffi::c_void,
                h_desc.raw,
                hx_ptr as *const std::ffi::c_void,
                y_desc.raw,
                y_ptr as *const std::ffi::c_void,
                work_space.len(),
                work_space_ptr as *mut std::ffi::c_void,
                dweight_space.len(),
                dweight_space_ptr as *mut std::ffi::c_void,
                reserve_space.len(),
                reserve_space_ptr as *mut std::ffi::c_void,
            )
            .into_result()
        }
    }
/// This function computes exact, first-order derivatives of the RNN model with respect to all
/// trainable parameters: weights and biases.
///
/// This function should ne called after `rnn_forward()`.
///
/// Gradient of the loss function with respect to weights and biases is typically computed over
/// multiple mini-batches. In such a case, partial results computed for each mini-batch should
/// be aggregated. The `add_grad` argument specifies if gradients from the current mini-batch
/// should be added to previously computed results (`WGradMode::Add`) or the `dweight_space`
/// buffer should be overwritten with the new results (`WGradMode::Set`).
///
/// All gradient results with respect to weights and biases are written to the `d_weight_space`
/// buffer. The size and the organization of the `d_weight_space` buffer is the same as the
/// `weight_space` buffer that holds RNN weights and biases.
///
/// **Do note that** currently, this function supports the `WGradMode::Add` mode only so the
/// `d_weight_space` buffer should be zeroed by the user before invoking the routine for the
/// first time. The same sequence lengths must be specified in the `x_desc` descriptor and in
/// the device array `device_seq_lengths`.
///
/// # Arguments
///
/// * `rnn_desc` - RNN descriptor.
///
/// * `add_grad` -  weight gradient output mode. Only `WGradMode::Add` is supported.
///
/// * `device_seq_lengths` -  a copy of `seq_lengths` from `x_desc` or `y_desc` RNN data
/// descriptors. The `device_seq_lengths` array must be stored in GPU memory as it is accessed
/// asynchronously by GPU kernels, possibly after this function exists.
///
/// * `x_desc` -  a descriptor corresponding to the RNN model primary input.
///
/// * `x` - GPU memory associated with the RNN data descriptor `x_desc`.
///
/// * `h_desc` - a tensor descriptor describing the initial RNN hidden state. This is the same
/// tensor descriptor as used in prior `rnn_forward()` and `rnn_backward_data()` calls.
///
/// * `hx` -  GPU buffer with the RNN initial hidden state. The same buffer `hx` should be
/// provided in prior `rnn_forward()` and `rnn_backward_data()` calls.
///
/// * `y_desc` - previously initialized descriptor corresponding to the RNN model primary
/// output. The data type, layout, `max_seq_length`, `batch_size`, and `seq_lengths` need to
/// match that of `x_desc`. This is the same RNN data descriptor as used in prior
/// `rnn_forward()` and `rnn_backward_data()` calls.
///
/// * `y` - GPU buffer holding the model's primary output.
///
/// * `dweight_space` - weights gradient space buffer in GPU memory.
///
/// * `work_space` - workspace buffer in GPU memory to store temporary data.
///
/// * `reserve_space` - reserve-space buffer in GPU memory.
///
/// # Errors
///
/// Returns errors if an invalid or incompatible input argument combinations was encountered.
This function computes exact, first-order derivatives of the RNN model with respect to all
trainable parameters: weights and biases.

This function should ne called after `rnn_forward()`.

Gradient of the loss function with respect to weights and biases is typically computed over
multiple mini-batches. In such a case, partial results computed for each mini-batch should
be aggregated.

All gradient results with respect to weights and biases are written to the `d_weight_space`
buffer. The size and the organization of the `d_weight_space` buffer is the same as the
`weight_space` buffer that holds RNN weights and biases.

Do note that** currently, this function supports the `WGradMode::Add` mode only so the
`d_weight_space` buffer should be zeroed by the user before invoking the routine for the
first time. The same sequence lengths must be specified in the `x_desc` descriptor and in
the device array `device_seq_lengths`.
This function computes exact first - order derivatives of the RNN model with respect to all trainable parameters : weights and biases . This function should ne called after ` rnn_forward () ` . Gradient of the loss function with respect to weights and biases is typically computed over multiple mini - batches . In such a case partial results computed for each mini - batch should be aggregated . All gradient results with respect to weights and biases are written to the ` d_weight_space ` buffer . The size and the organization of the ` d_weight_space ` buffer is the same as the ` weight_space ` buffer that holds RNN weights and biases . Do note that ** currently this function supports the ` WGradMode :: Add ` mode only so the ` d_weight_space ` buffer should be zeroed by the user before invoking the routine for the first time . The same sequence lengths must be specified in the ` x_desc ` descriptor and in the device array ` device_seq_lengths ` .
pub fn rnn_backward_weights<T1, T2, L>(
        &self,
        rnn_desc: &RnnDescriptor<T1, T2>,
        add_grad: WGradMode,
        device_seq_lengths: &impl GpuBuffer<i32>,
        x_desc: &RnnDataDescriptor<T1, L>,
        x: &impl GpuBuffer<T1>,
        h_desc: &TensorDescriptor<T1, NCHW, 3>,
        hx: &impl GpuBuffer<T1>,
        y_desc: &RnnDataDescriptor<T1, L>,
        y: &impl GpuBuffer<T1>,
        dweight_space: &mut impl GpuBuffer<u8>,
        work_space: &mut impl GpuBuffer<u8>,
        reserve_space: &mut impl GpuBuffer<u8>,
    ) -> Result<(), CudnnError>
    where
        T1: DataType + RnnDataType,
        T2: DataType + SupportedPrec<T1>,
        L: RnnDataLayout,
        NCHW: SupportedType<T1>,
    {
        let device_sequence_lengths_ptr = device_seq_lengths.as_device_ptr().as_raw();
        let x_ptr = x.as_device_ptr().as_raw();
        let hx_ptr = x.as_device_ptr().as_raw();
        let y_ptr = y.as_device_ptr().as_raw();
        let dweight_space_ptr = dweight_space.as_device_ptr().as_raw_mut();
        let work_space_ptr = work_space.as_device_ptr().as_raw_mut();
        let reserve_space_ptr = reserve_space.as_device_ptr().as_raw_mut();
        unsafe {
            sys::cudnnRNNBackwardWeights_v8(
                self.raw,
                rnn_desc.raw,
                add_grad.into(),
                device_sequence_lengths_ptr,
                x_desc.raw,
                x_ptr as *const std::ffi::c_void,
                h_desc.raw,
                hx_ptr as *const std::ffi::c_void,
                y_desc.raw,
                y_ptr as *const std::ffi::c_void,
                work_space.len(),
                work_space_ptr as *mut std::ffi::c_void,
                dweight_space.len(),
                dweight_space_ptr as *mut std::ffi::c_void,
                reserve_space.len(),
                reserve_space_ptr as *mut std::ffi::c_void,
            )
            .into_result()
        }
    }
pub fn rnn_backward_weights < T1 , T2 , L > ( & self , rnn_desc : & RnnDescriptor < T1 , T2 > , add_grad : WGradMode , device_seq_lengths : & impl GpuBuffer < i32 > , x_desc : & RnnDataDescriptor < T1 , L > , x : & impl GpuBuffer < T1 > , h_desc : & TensorDescriptor < T1 , NCHW , 3 > , hx : & impl GpuBuffer < T1 > , y_desc : & RnnDataDescriptor < T1 , L > , y : & impl GpuBuffer < T1 > , dweight_space : & mut impl GpuBuffer < u8 > , work_space : & mut impl GpuBuffer < u8 > , reserve_space : & mut impl GpuBuffer < u8 > , ) -> Result < ( ) , CudnnError > where T1 : DataType + RnnDataType , T2 : DataType + SupportedPrec < T1 > , L : RnnDataLayout , NCHW : SupportedType < T1 > , { let device_sequence_lengths_ptr = device_seq_lengths . as_device_ptr ( ) . as_raw ( ) ; let x_ptr = x . as_device_ptr ( ) . as_raw ( ) ; let hx_ptr = x . as_device_ptr ( ) . as_raw ( ) ; let y_ptr = y . as_device_ptr ( ) . as_raw ( ) ; let dweight_space_ptr = dweight_space . as_device_ptr ( ) . as_raw_mut ( ) ; let work_space_ptr = work_space . as_device_ptr ( ) . as_raw_mut ( ) ; let reserve_space_ptr = reserve_space . as_device_ptr ( ) . as_raw_mut ( ) ; unsafe { sys :: cudnnRNNBackwardWeights_v8 ( self . raw , rnn_desc . raw , add_grad . into ( ) , device_sequence_lengths_ptr , x_desc . raw , x_ptr as * const std :: ffi :: c_void , h_desc . raw , hx_ptr as * const std :: ffi :: c_void , y_desc . raw , y_ptr as * const std :: ffi :: c_void , work_space . len ( ) , work_space_ptr as * mut std :: ffi :: c_void , dweight_space . len ( ) , dweight_space_ptr as * mut std :: ffi :: c_void , reserve_space . len ( ) , reserve_space_ptr as * mut std :: ffi :: c_void , ) . into_result ( ) } }
This function computes exact, first-order derivatives of the RNN model with respect to all
trainable parameters: weights and biases.
This function computes exact first - order derivatives of the RNN model with respect to all trainable parameters : weights and biases .
&self
rnn_desc
&RnnDescriptor<T1, T2>
add_grad
WGradMode
device_seq_lengths
&impl GpuBuffer<i32>
x_desc
&RnnDataDescriptor<T1, L>
x
&impl GpuBuffer<T1>
h_desc
&TensorDescriptor<T1, NCHW, 3>
hx
&impl GpuBuffer<T1>
y_desc
&RnnDataDescriptor<T1, L>
y
&impl GpuBuffer<T1>
dweight_space
&mut impl GpuBuffer<u8>
work_space
&mut impl GpuBuffer<u8>
reserve_space
&mut impl GpuBuffer<u8>
&self
rnn_desc
&RnnDescriptor<T1, T2>
add_grad
WGradMode
device_seq_lengths
&impl GpuBuffer<i32>
x_desc
&RnnDataDescriptor<T1, L>
x
&impl GpuBuffer<T1>
h_desc
&TensorDescriptor<T1, NCHW, 3>
hx
&impl GpuBuffer<T1>
y_desc
&RnnDataDescriptor<T1, L>
y
&impl GpuBuffer<T1>
dweight_space
&mut impl GpuBuffer<u8>
work_space
&mut impl GpuBuffer<u8>
reserve_space
&mut impl GpuBuffer<u8>
errors
Returns errors if an invalid or incompatible input argument combinations was encountered.
Returns errors if an invalid or incompatible input argument combinations was encountered .