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
| 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 | /// |
nothing calls this directly
no test coverage detected