MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / dropout_forward

Method dropout_forward

crates/cudnn/src/context.rs:384–417  ·  view source on GitHub ↗

This function performs forward dropout operation over `x` returning results in `y`. The approximate dropout fraction of x values will be replaced by a 0, and the rest will be scaled by 1 / (1 - dropout), i.e. the value configured in `dropout_desc`. This function should not be running concurrently with another `dropout_forward()` function using the same states, as defined in the `DropoutDescripto

(
        &self,
        dropout_desc: &DropoutDescriptor<impl GpuBuffer<u8>>,
        x: &Tensor<T, F1, impl GpuBuffer<T>, D>,
        y: &mut Tensor<T, F2, impl GpuBuffer<T>, D>,
        reserve_spa

Source from the content-addressed store, hash-verified

382 /// Returns an error if the number of elements in `x` and `y` differs and if `reserve_space` is
383 /// less than the value returned by `get_dropout_reserve_space_size`.
384 pub fn dropout_forward<T, F1, F2, const D: usize>(
385 &self,
386 dropout_desc: &DropoutDescriptor<impl GpuBuffer<u8>>,
387 x: &Tensor<T, F1, impl GpuBuffer<T>, D>,
388 y: &mut Tensor<T, F2, impl GpuBuffer<T>, D>,
389 reserve_space: &mut impl GpuBuffer<u8>,
390 ) -> Result<(), CudnnError>
391 where
392 T: DataType,
393 F1: TensorFormat + SupportedType<T>,
394 F2: TensorFormat + SupportedType<T>,
395 {
396 let x_desc = x.descriptor();
397 let x_data = x.data().as_device_ptr().as_raw();
398
399 let y_desc = y.descriptor();
400 let y_data = y.data().as_device_ptr().as_ptr();
401
402 let reserve_space_ptr = reserve_space.as_device_ptr().as_ptr();
403
404 unsafe {
405 sys::cudnnDropoutForward(
406 self.raw,
407 dropout_desc.raw,
408 x_desc.raw,
409 x_data as *const std::ffi::c_void,
410 y_desc.raw,
411 y_data as *mut std::ffi::c_void,
412 reserve_space_ptr as *mut std::ffi::c_void,
413 reserve_space.len(),
414 )
415 .into_result()
416 }
417 }
418
419 /// This function performs backward dropout operation over `dy` returning results in `dx`.
420 ///

Callers

nothing calls this directly

Calls 7

as_ptrMethod · 0.80
descriptorMethod · 0.45
as_rawMethod · 0.45
as_device_ptrMethod · 0.45
dataMethod · 0.45
into_resultMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected