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

Method convolution_forward

crates/cudnn/src/context.rs:1148–1217  ·  view source on GitHub ↗

This function executes convolutions or cross-correlations over `x` using a filter specified with `w`, returning results in `y`. # Arguments `alpha` - scaling parameter. `x` - input map. `w` - filter. `conv_desc` - convolution descriptor. `algo` - convolution algorithm that should be used to compute the result. `work_space` - a buffer to GPU memory to a workspace needed to be able to execut

(
        &self,
        alpha: CompType,
        x: &Tensor<T1, F1, impl GpuBuffer<T1>, D>,
        w: &Filter<T2, F2, impl GpuBuffer<T2>, D>,
        conv_desc: &ConvolutionDescriptor<CompType, N>,

Source from the content-addressed store, hash-verified

1146 /// are supported by cuDNN. Refer to the following link for the
1147 /// [complete list](https://docs.nvidia.com/deeplearning/cudnn/api/index.html#cudnnConvolutionForward).
1148 pub fn convolution_forward<
1149 T1,
1150 F1,
1151 T2,
1152 F2,
1153 CompType,
1154 T3,
1155 F3,
1156 A,
1157 W,
1158 const D: usize,
1159 const N: usize,
1160 >(
1161 &self,
1162 alpha: CompType,
1163 x: &Tensor<T1, F1, impl GpuBuffer<T1>, D>,
1164 w: &Filter<T2, F2, impl GpuBuffer<T2>, D>,
1165 conv_desc: &ConvolutionDescriptor<CompType, N>,
1166 algo: &A,
1167 work_space: Option<&mut W>,
1168 beta: CompType,
1169 y: &mut Tensor<T3, F3, impl GpuBuffer<T3>, D>,
1170 ) -> Result<(), CudnnError>
1171 where
1172 T1: DataType,
1173 F1: TensorFormat + SupportedType<T1>,
1174 T2: DataType,
1175 F2: TensorFormat + SupportedType<T2>,
1176 CompType: DataType,
1177 T3: DataType,
1178 F3: TensorFormat + SupportedType<T3>,
1179 A: ConvolutionFwdAlgo + SupportedConvFwd<T1, F1, T2, F2, CompType, T3, F3, D, N>,
1180 W: GpuBuffer<u8>,
1181 {
1182 let x_data = x.data().as_device_ptr().as_raw();
1183 let x_desc = x.descriptor();
1184
1185 let w_data = w.data().as_device_ptr().as_raw();
1186 let w_desc = w.descriptor();
1187
1188 let y_data = y.data().as_device_ptr().as_ptr();
1189 let y_desc = y.descriptor();
1190
1191 // If the _ size is 0 then the algorithm can work in-place and cuDNN expects a null
1192 // pointer.
1193 let (work_space_ptr, work_space_size): (*mut u8, usize) = {
1194 work_space.map_or((std::ptr::null_mut(), 0), |work_space| {
1195 (work_space.as_device_ptr().as_mut_ptr(), work_space.len())
1196 })
1197 };
1198
1199 unsafe {
1200 sys::cudnnConvolutionForward(
1201 self.raw,
1202 &alpha as *const CompType as *const std::ffi::c_void,
1203 x_desc.raw,
1204 x_data as *const std::ffi::c_void,
1205 w_desc.raw,

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected