Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__add__ fails for empty array inputs #391

Open
mitkotak opened this issue Oct 27, 2022 · 0 comments
Open

__add__ fails for empty array inputs #391

mitkotak opened this issue Oct 27, 2022 · 0 comments
Labels

Comments

@mitkotak
Copy link
Contributor

Here's the MWE

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> empty_array = np.array([])
>>> empty_array_gpu = gpuarray.to_gpu(empty_array)
>>> result_array = empty_array + 0 # array([], dtype=float64)
>>> result_array_gpu = -empty_array_gpu + 0 # Fails

Here's the error trace

---------------------------------------------------------------------------
ArgumentError                             Traceback (most recent call last)
Input In [29], in <cell line: 1>()
----> 1 empty_array_gpu + 0

File ~/pycuda/pycuda/gpuarray.py:593, in GPUArray.__add__(self, other)
    590 elif np.isscalar(other):
    591     # add a scalar
    592     if other == 0:
--> 593         return self.copy()
    594     else:
    595         result = self._new_like_me(_get_common_dtype(self, other))

File ~/pycuda/pycuda/gpuarray.py:393, in GPUArray.copy(self)
    391 def copy(self):
    392     new = GPUArray(self.shape, self.dtype, self.allocator)
--> 393     _memcpy_discontig(new, self)
    394     return new

File ~/pycuda/pycuda/gpuarray.py:1570, in _memcpy_discontig(dst, src, async_, stream)
   1566         drv.memcpy_dtod_async(
   1567             dst.gpudata, src.gpudata, src.nbytes, stream=stream
   1568         )
   1569     else:
-> 1570         drv.memcpy_dtod(dst.gpudata, src.gpudata, src.nbytes)
   1571 else:
   1572     # The arrays might be contiguous in the sense of
   1573     # having no gaps, but the axes could be transposed
   1574     # so that the order is neither Fortran or C.
   1575     # So, we attempt to get a contiguous view of dst.
   1576     dst = _as_strided(dst, shape=(dst.size,), strides=(dst.dtype.itemsize,))

ArgumentError: Python argument types in
    pycuda._driver.memcpy_dtod(NoneType, NoneType, int)
did not match C++ signature:
    memcpy_dtod(unsigned long long dest, unsigned long long src, unsigned long size)
@mitkotak mitkotak added the bug label Oct 27, 2022
@mitkotak mitkotak changed the title __add__ fails for empty array operations __add__ fails for empty arrays Oct 27, 2022
@mitkotak mitkotak changed the title __add__ fails for empty arrays __add__ fails for empty array inputs Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant