def may_share_memory(a, b, raise_other_type=True): a_ndarray = isinstance(a, np.ndarray) b_ndarray = isinstance(b, np.ndarray) if a_ndarray and b_ndarray: return TensorType.may_share_memory(a, b) a_cuda = _is_cuda(a) b_cuda = _is_cuda(b) if a_cuda and b_cuda: return CudaNdarrayType.may_share_memory(a, b) a_gpua = _is_gpua(a) b_gpua = _is_gpua(b) if a_gpua and b_gpua: return gpuarray.pygpu.gpuarray.may_share_memory(a, b) a_sparse = _is_sparse(a) b_sparse = _is_sparse(b) if (not (a_ndarray or a_sparse or a_cuda or a_gpua) or not (b_ndarray or b_sparse or b_cuda or b_gpua)): if raise_other_type: raise TypeError("may_share_memory support only ndarray" " and scipy.sparse, CudaNdarray or GpuArray type") return False if a_cuda or b_cuda or a_gpua or b_gpua: return False return SparseType.may_share_memory(a, b)
def may_share_memory(a, b, raise_other_type=True): a_ndarray = isinstance(a, np.ndarray) b_ndarray = isinstance(b, np.ndarray) if a_ndarray and b_ndarray: return TensorType.may_share_memory(a, b) a_cuda = _is_cuda(a) b_cuda = _is_cuda(b) if a_cuda and b_cuda: return CudaNdarrayType.may_share_memory(a, b) a_gpua = _is_gpua(a) b_gpua = _is_gpua(b) if a_gpua and b_gpua: return gpuarray.pygpu.gpuarray.may_share_memory(a, b) a_sparse = _is_sparse(a) b_sparse = _is_sparse(b) if (not(a_ndarray or a_sparse or a_cuda or a_gpua) or not(b_ndarray or b_sparse or b_cuda or b_gpua)): if raise_other_type: raise TypeError("may_share_memory support only ndarray" " and scipy.sparse, CudaNdarray or GpuArray type") return False if a_cuda or b_cuda or a_gpua or b_gpua: return False return SparseType.may_share_memory(a, b)
def may_share_memory(a, b, raise_other_type=True): a_ndarray = isinstance(a, numpy.ndarray) b_ndarray = isinstance(b, numpy.ndarray) a_sparse = _is_sparse(a) b_sparse = _is_sparse(b) a_cuda = _is_cuda(a) b_cuda = _is_cuda(b) if not(a_ndarray or a_sparse or a_cuda) or not(b_ndarray or b_sparse or b_cuda): if raise_other_type: raise TypeError("may_share_memory support only ndarray and scipy.sparse and CudaNdarray type") return False if a_ndarray and b_ndarray: return TensorType.may_share_memory(a,b) if a_cuda and b_cuda: from theano.sandbox.cuda.type import CudaNdarrayType return CudaNdarrayType.may_share_memory(a,b) if a_cuda or b_cuda: return False return SparseType.may_share_memory(a,b)
def may_share_memory(a, b, raise_other_type=True): a_ndarray = isinstance(a, numpy.ndarray) b_ndarray = isinstance(b, numpy.ndarray) a_sparse = _is_sparse(a) b_sparse = _is_sparse(b) a_cuda = _is_cuda(a) b_cuda = _is_cuda(b) if (not (a_ndarray or a_sparse or a_cuda) or not (b_ndarray or b_sparse or b_cuda)): if raise_other_type: raise TypeError("may_share_memory support only ndarray" " and scipy.sparse and CudaNdarray type") return False if a_ndarray and b_ndarray: return TensorType.may_share_memory(a, b) if a_cuda and b_cuda: from theano.sandbox.cuda.type import CudaNdarrayType return CudaNdarrayType.may_share_memory(a, b) if a_cuda or b_cuda: return False return SparseType.may_share_memory(a, b)