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

Method convolution_backward_data

crates/cudnn/src/context.rs:1250–1317  ·  view source on GitHub ↗

This function computes the convolution data gradient of the tensor `dy`, where `y` is the output of the forward convolution in `convolution_forward`. It uses the specified algo, and returns the results in the output tensor `dx`. Scaling factors `alpha` and `beta` can be used to scale the computed result or accumulate with the current `dx`. # Arguments `alpha` - scaling parameter. `w` - filter.

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

Source from the content-addressed store, hash-verified

1248 /// are supported by cuDNN. Refer to the following link for the
1249 /// [complete list](https://docs.nvidia.com/deeplearning/cudnn/api/index.html#cudnnConvolutionBackwardData).
1250 pub fn convolution_backward_data<
1251 T1,
1252 F1,
1253 T2,
1254 F2,
1255 CompType,
1256 T3,
1257 F3,
1258 A,
1259 W,
1260 const D: usize,
1261 const N: usize,
1262 >(
1263 &self,
1264 alpha: CompType,
1265 w: &Filter<T1, F1, impl GpuBuffer<T1>, D>,
1266 dy: &Tensor<T2, F2, impl GpuBuffer<T2>, D>,
1267 conv_desc: &ConvolutionDescriptor<CompType, N>,
1268 algo: &A,
1269 work_space: Option<&mut W>,
1270 beta: CompType,
1271 dx: &mut Tensor<T3, F3, impl GpuBuffer<T3>, D>,
1272 ) -> Result<(), CudnnError>
1273 where
1274 T1: DataType,
1275 F1: TensorFormat + SupportedType<T1>,
1276 T2: DataType,
1277 F2: TensorFormat + SupportedType<T2>,
1278 CompType: DataType,
1279 T3: DataType,
1280 F3: TensorFormat + SupportedType<T3>,
1281 A: ConvolutionBwdDataAlgo + SupportedConvBwdData<T1, F1, T2, F2, CompType, T3, F3, D, N>,
1282 W: GpuBuffer<u8>,
1283 {
1284 let w_data = w.data().as_device_ptr().as_raw();
1285 let w_desc = w.descriptor();
1286
1287 let dy_data = dy.data().as_device_ptr().as_raw();
1288 let dy_desc = dy.descriptor();
1289
1290 let dx_data = dx.data().as_device_ptr().as_ptr();
1291 let dx_desc = dx.descriptor();
1292
1293 let (work_space_ptr, work_space_size): (*mut u8, usize) = {
1294 work_space.map_or((std::ptr::null_mut(), 0), |work_space| {
1295 (work_space.as_device_ptr().as_mut_ptr(), work_space.len())
1296 })
1297 };
1298
1299 unsafe {
1300 sys::cudnnConvolutionBackwardData(
1301 self.raw,
1302 &alpha as *const CompType as *const std::ffi::c_void,
1303 w_desc.raw,
1304 w_data as *const std::ffi::c_void,
1305 dy_desc.raw,
1306 dy_data as *const std::ffi::c_void,
1307 conv_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