def dnn_gradinput(kerns, topgrad, img_shp, border_mode='valid', subsample=(1, 1), conv_mode='conv'):
 kerns = gpu_contiguous(kerns)
 topgrad = gpu_contiguous(topgrad)
 img_shp = theano.tensor.as_tensor_variable(img_shp)
 desc = GpuDnnConvDesc(border_mode=border_mode, subsample=subsample, conv_mode=conv_mode)(img_shp, kerns.shape)
 out = gpu_alloc_empty(*img_shp)
 return GpuDnnConvGradI()(kerns, topgrad, out, desc)

def dnn_gradinput ( kerns , topgrad , img_shp , border_mode = 'valid' , subsample = ( 1 , 1 ) , conv_mode = 'conv' ) : kerns = gpu_contiguous ( kerns ) topgrad = gpu_contiguous ( topgrad ) img_shp = theano . tensor . as_tensor_variable ( img_shp ) desc = GpuDnnConvDesc ( border_mode = border_mode , subsample = subsample , conv_mode = conv_mode ) ( img_shp , kerns . shape ) out = gpu_alloc_empty ( * img_shp ) return GpuDnnConvGradI ( ) ( kerns , topgrad , out , desc )
gpu convolution gradient with respect to input using cudnn from nvidia .