def dnn_pool(img, ws, stride=None, mode='max', pad=None):
 img = gpu_contiguous(img)
 if (stride is None):
  stride = ((1,) * len(ws))
 if (pad is None):
  pad = ((0,) * len(ws))
 if (mode == 'sum'):
  ret = GpuDnnPool(mode='average_inc_pad')(img, ws, stride, pad)
  window_elem = theano.tensor.prod(ws).astype(ret.dtype)
  return as_cuda_ndarray_variable((ret * window_elem))
 return GpuDnnPool(mode=mode)(img, ws, stride, pad)

def dnn_pool ( img , ws , stride = None , mode = 'max' , pad = None ) : img = gpu_contiguous ( img ) if ( stride is None ) : stride = ( ( 1 , ) * len ( ws ) ) if ( pad is None ) : pad = ( ( 0 , ) * len ( ws ) ) if ( mode == 'sum' ) : ret = GpuDnnPool ( mode = 'average_inc_pad' ) ( img , ws , stride , pad ) window_elem = theano . tensor . prod ( ws ) . astype ( ret . dtype ) return as_cuda_ndarray_variable ( ( ret * window_elem ) ) return GpuDnnPool ( mode = mode ) ( img , ws , stride , pad )
gpu pooling using cudnn from nvidia .