pub fn create_dropout_descriptor<T: GpuBuffer<u8>>(
        &self,
        dropout: f32,
        states: T,
        seed: u64,
    ) -> Result<DropoutDescriptor<T>, CudnnError> {
        let mut raw = MaybeUninit::uninit();

        unsafe {
            sys::cudnnCreateDropoutDescriptor(raw.as_mut_ptr()).into_result()?;

            let mut raw = raw.assume_init();

            sys::cudnnSetDropoutDescriptor(
                raw,
                self.raw,
                dropout,
                states.as_device_ptr().as_raw_mut() as *mut std::ffi::c_void,
                states.len(),
                seed,
            )
            .into_result()?;

            Ok(DropoutDescriptor::new(raw, states))
        }
    }
/// Creates and initializes a generic dropout descriptor.
///
/// # Arguments
///
/// * `dropout` - probability with which the value from input is set to zero during the dropout
/// layer.
///
/// * `states` - user-allocated GPU memory that will hold random number generator states.
///
/// * `seed` - seed used to initialize random number generator states.
///
/// **Do note** that the exact amount of memory can be obtained with `get_dropout_states_size`.
///
/// # Errors
///
/// Return errors if `states` size is less than that returned by `get_dropout_states_size`.
///
/// # Examples
///
/// ```
/// # use std::error::Error;
/// #
/// # fn main() -> Result<(), Box<dyn Error>> {
/// use cudnn::{CudnnContext};
/// use cust::memory::DeviceBuffer;
///
/// let ctx = CudnnContext::new()?;
///
/// let size = ctx.get_dropout_states_size()?;
/// let states = unsafe { DeviceBuffer::uninitialized(size)? };
///
/// let dropout = 0.5;
/// let seed = 123;
///
/// let dropout_desc = ctx.create_dropout_descriptor(dropout, states, seed)?;
/// # Ok(())
/// # }
/// ```
Creates and initializes a generic dropout descriptor.
Creates and initializes a generic dropout descriptor .
pub fn create_dropout_descriptor<T: GpuBuffer<u8>>(
        &self,
        dropout: f32,
        states: T,
        seed: u64,
    ) -> Result<DropoutDescriptor<T>, CudnnError> {
        let mut raw = MaybeUninit::uninit();
        unsafe {
            sys::cudnnCreateDropoutDescriptor(raw.as_mut_ptr()).into_result()?;
            let mut raw = raw.assume_init();
            sys::cudnnSetDropoutDescriptor(
                raw,
                self.raw,
                dropout,
                states.as_device_ptr().as_raw_mut() as *mut std::ffi::c_void,
                states.len(),
                seed,
            )
            .into_result()?;
            Ok(DropoutDescriptor::new(raw, states))
        }
    }
pub fn create_dropout_descriptor < T : GpuBuffer < u8 > > ( & self , dropout : f32 , states : T , seed : u64 , ) -> Result < DropoutDescriptor < T > , CudnnError > { let mut raw = MaybeUninit :: uninit ( ) ; unsafe { sys :: cudnnCreateDropoutDescriptor ( raw . as_mut_ptr ( ) ) . into_result ( ) ? ; let mut raw = raw . assume_init ( ) ; sys :: cudnnSetDropoutDescriptor ( raw , self . raw , dropout , states . as_device_ptr ( ) . as_raw_mut ( ) as * mut std :: ffi :: c_void , states . len ( ) , seed , ) . into_result ( ) ? ; Ok ( DropoutDescriptor :: new ( raw , states ) ) } }
Creates and initializes a generic dropout descriptor.
Creates and initializes a generic dropout descriptor .
&self
dropout
f32
states
T
seed
u64
&self
dropout
f32
states
T
seed
u64
errors
Return errors if `states` size is less than that returned by `get_dropout_states_size`.
Return errors if ` states ` size is less than that returned by ` get_dropout_states_size ` .
examples
None
use std::error::error;
None
fn main() -> result<(), box<dyn error>> {
use cudnn::{CudnnContext};
use cust::memory::DeviceBuffer.

let ctx = CudnnContext::new()?.

let size = ctx.get_dropout_states_size()?;
let states = unsafe { DeviceBuffer::uninitialized(size).



let dropout_desc = ctx.create_dropout_descriptor(dropout, states, seed)?.
use cudnn :: { CudnnContext } ; use cust :: memory :: DeviceBuffer . let ctx = CudnnContext :: new () ? . let size = ctx . get_dropout_states_size () ? ; let states = unsafe { DeviceBuffer :: uninitialized ( size ) . let dropout_desc = ctx . create_dropout_descriptor ( dropout states seed ) ? .
ok(())
None
}
None