def dnn_gradinput3d(kerns, topgrad, img_shp, border_mode='valid', subsample=(1, 1, 1), conv_mode='conv'):
 ctx_name = infer_context_name(kerns, topgrad)
 kerns = as_gpuarray_variable(kerns, ctx_name)
 topgrad = as_gpuarray_variable(topgrad, ctx_name)
 kerns = gpu_contiguous(kerns)
 topgrad = gpu_contiguous(topgrad)
 img_shp = as_tensor_variable(img_shp)
 desc = gpu_dnn_conv_desc(border_mode=border_mode, subsample=subsample, conv_mode=conv_mode)(kerns.shape)
 out = gpu_alloc_empty(ctx_name, kerns.dtype)(*img_shp)
 return gpu_dnn_conv_gradI()(kerns, topgrad, out, desc)

def dnn_gradinput3d ( kerns , topgrad , img_shp , border_mode = 'valid' , subsample = ( 1 , 1 , 1 ) , conv_mode = 'conv' ) : ctx_name = infer_context_name ( kerns , topgrad ) kerns = as_gpuarray_variable ( kerns , ctx_name ) topgrad = as_gpuarray_variable ( topgrad , ctx_name ) kerns = gpu_contiguous ( kerns ) topgrad = gpu_contiguous ( topgrad ) img_shp = as_tensor_variable ( img_shp ) desc = gpu_dnn_conv_desc ( border_mode = border_mode , subsample = subsample , conv_mode = conv_mode ) ( kerns . shape ) out = gpu_alloc_empty ( ctx_name , kerns . dtype ) ( * img_shp ) return gpu_dnn_conv_gradI ( ) ( kerns , topgrad , out , desc )
gpu convolution gradient with respect to input using cudnn from nvidia .