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

0 sized array operations fail #373

Open
mitkotak opened this issue Aug 16, 2022 · 1 comment
Open

0 sized array operations fail #373

mitkotak opened this issue Aug 16, 2022 · 1 comment
Labels

Comments

@mitkotak
Copy link
Contributor

Here's the MWE

>>> import pycuda.autoinit
>>> import pycuda.gpuarray as gpuarray
>>> import numpy as np
>>> empty = np.array([])
>>> empty_gpu = gpuarray.to_gpu(empty)
>>> empty + empty # Passes 
>>> empty_gpu + empty_gpu # Fails

Here's the error trace

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
Input In [7], in <cell line: 7>()
      5 empty_gpu = gpuarray.to_gpu(empty)
      6 empty + empty # Passes
----> 7 empty_gpu + empty_gpu

File ~/pycuda/pycuda/gpuarray.py:588, in GPUArray.__add__(self, other)
    585 if isinstance(other, GPUArray):
    586     # add another vector
    587     result = _get_broadcasted_binary_op_result(self, other)
--> 588     return self._axpbyz(1, other, 1, result)
    590 elif np.isscalar(other):
    591     # add a scalar
    592     if other == 0:

File ~/pycuda/pycuda/gpuarray.py:445, in GPUArray._axpbyz(self, selffac, other, otherfac, out, add_timer, stream)
    432     add_timer(
    433         3 * self.size,
    434         func.prepared_timed_call(
   (...)
    442         ),
    443     )
    444 else:
--> 445     func.prepared_async_call(
    446         out._grid,
    447         out._block,
    448         stream,
    449         selffac,
    450         self.gpudata,
    451         otherfac,
    452         other.gpudata,
    453         out.gpudata,
    454         out.mem_size,
    455     )
    457 return out

File ~/pycuda/pycuda/driver.py:625, in _add_functionality.<locals>.function_prepared_async_call(func, grid, block, stream, *args, **kwargs)
    619     raise TypeError(
    620         "unknown keyword arguments: " + ", ".join(kwargs.keys())
    621     )
    623 from pycuda._pvt_struct import pack
--> 625 arg_buf = pack(func.arg_format, *args)
    627 for texref in func.texrefs:
    628     func.param_set_texref(texref)

error: required argument is not an integer
@mitkotak mitkotak added the bug label Aug 16, 2022
@kaushikcfd
Copy link
Contributor

There's a proposed fix for this at https://gitlab.tiker.net/inducer/pycuda/-/merge_requests/75.

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

2 participants