def create_pooling_descriptor(ksize, stride, pad, mode): desc = Descriptor(cudnn.createPoolingDescriptor(), cudnn.destroyPoolingDescriptor) ndim = len(ksize) if ndim != len(stride) or ndim != len(pad): raise ValueError('ksize, stride, and pad must be of same length') if ndim == 2: if _cudnn_version >= 4000: cudnn.setPooling2dDescriptor_v4( desc.value, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: cudnn.setPooling2dDescriptor_v3( desc.value, mode, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: c_ksize = _to_ctypes_array(ksize) c_pad = _to_ctypes_array(pad) c_stride = _to_ctypes_array(stride) if _cudnn_version >= 4000: cudnn.setPoolingNdDescriptor_v4( desc.value, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ndim, c_ksize.data, c_pad.data, c_stride.data) else: cudnn.setPoolingNdDescriptor_v3( desc.value, mode, ndim, c_ksize.data, c_pad.data, c_stride.data) return desc
def create_pooling_descriptor(ksize, stride, pad, mode): desc = Descriptor(cudnn.createPoolingDescriptor(), cudnn.destroyPoolingDescriptor) ndim = len(ksize) if ndim != len(stride) or ndim != len(pad): raise ValueError('ksize, stride, and pad must be of same length') if ndim == 2: if _cudnn_version >= 4000: cudnn.setPooling2dDescriptor_v4( desc.value, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: cudnn.setPooling2dDescriptor_v3( desc.value, mode, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: c_ksize = _to_ctypes_array(ksize) c_pad = _to_ctypes_array(pad) c_stride = _to_ctypes_array(stride) if _cudnn_version >= 4000: cudnn.setPoolingNdDescriptor_v4( desc.value, mode, cudnn.CUDNN_NOT_PROPAGATE_NAN, ndim, c_ksize.data, c_pad.data, c_stride.data) else: cudnn.setPoolingNdDescriptor_v3( desc.value, mode, ndim, c_ksize.data, c_pad.data, c_stride.data) return desc
def create_pooling_descriptor(ksize, stride, pad, mode): desc = Descriptor(cudnn.createPoolingDescriptor(), cudnn.destroyPoolingDescriptor) ndim = len(ksize) if ndim != len(stride) or ndim != len(pad): raise ValueError("ksize, stride, and pad must be of same length") if ndim == 2: cudnn.setPooling2dDescriptor_v3(desc.value, mode, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: c_ksize = _to_ctypes_array(ksize) c_pad = _to_ctypes_array(pad) c_stride = _to_ctypes_array(stride) cudnn.setPoolingNdDescriptor_v3(desc.value, mode, ndim, c_ksize.data, c_pad.data, c_stride.data) return desc
def create_pooling_descriptor(ksize, stride, pad, mode): desc = Descriptor(cudnn.createPoolingDescriptor(), cudnn.destroyPoolingDescriptor) ndim = len(ksize) if ndim != len(stride) or ndim != len(pad): raise ValueError('ksize, stride, and pad must be of same length') if ndim == 2: cudnn.setPooling2dDescriptor( desc.value, mode, ksize[0], ksize[1], pad[0], pad[1], stride[0], stride[1]) else: cudnn.setPoolingNdDescriptor( desc.value, mode, ndim, _to_ctypes_array(ksize), _to_ctypes_array(pad), _to_ctypes_array(stride)) return desc