def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW): desc = Descriptor(cudnn.createTensorDescriptor(), cudnn.destroyTensorDescriptor) if arr.ndim != 4: raise ValueError("cupy.cudnn supports 4-dimensional arrays only") if not arr.flags.c_contiguous: raise ValueError("cupy.cudnn supports c-contiguous arrays only") data_type = get_data_type(arr.dtype) cudnn.setTensor4dDescriptor(desc.value, format, data_type, *arr.shape) return desc
def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW): desc = Descriptor(cudnn.createTensorDescriptor(), cudnn.destroyTensorDescriptor) if arr.ndim != 4: raise ValueError('cupy.cudnn supports 4-dimensional arrays only') if not arr.flags.c_contiguous: raise ValueError('cupy.cudnn supports c-contiguous arrays only') data_type = get_data_type(arr.dtype) cudnn.setTensor4dDescriptor(desc.value, format, data_type, *arr.shape) return desc
def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW): desc = Descriptor(cudnn.createTensorDescriptor(), cudnn.destroyTensorDescriptor) if not arr.flags.c_contiguous: raise ValueError("cupy.cudnn supports c-contiguous arrays only") data_type = get_data_type(arr.dtype) if arr.ndim == 4: cudnn.setTensor4dDescriptor(desc.value, format, data_type, *arr.shape) else: c_shape = _to_ctypes_array(arr.shape) c_strides = _to_ctypes_array(_compute_strides(arr.shape)) cudnn.setTensorNdDescriptor(desc.value, data_type, arr.ndim, c_shape.data, c_strides.data) return desc
def create_tensor_descriptor(arr, format=cudnn.CUDNN_TENSOR_NCHW): desc = Descriptor(cudnn.createTensorDescriptor(), cudnn.destroyTensorDescriptor) if not arr.flags.c_contiguous: raise ValueError('cupy.cudnn supports c-contiguous arrays only') data_type = get_data_type(arr.dtype) if arr.ndim == 4: cudnn.setTensor4dDescriptor(desc.value, format, data_type, *arr.shape) else: c_shape = _to_ctypes_array(arr.shape) c_strides = _to_ctypes_array(_compute_strides(arr.shape)) cudnn.setTensorNdDescriptor(desc.value, data_type, arr.ndim, c_shape.data, c_strides.data) return desc