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

GPUArray.zeros_like | ones_like failing for scalar inputs #389

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

GPUArray.zeros_like | ones_like failing for scalar inputs #389

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
>>> c = 42.0
>>> zero_array = np.zeros_like(c) # array(0.)
>>> zero_array_gpu = gpuarray.zeros_like(c) # Fails
>>> one_array = np.ones_like(c) # array(1.)
>>> one_array_gpu = gpuarray.ones_like(c) # Fails

Here's the error trace

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [15], in <cell line: 1>()
----> 1 gpuarray.zeros_like(c)

File ~/pycuda/pycuda/gpuarray.py:1422, in zeros_like(other_ary, dtype, order)
   1421 def zeros_like(other_ary, dtype=None, order="K"):
-> 1422     dtype, order, strides = _array_like_helper(other_ary, dtype, order)
   1423     result = GPUArray(
   1424         other_ary.shape, dtype, other_ary.allocator, order=order, strides=strides
   1425     )
   1426     zero = np.zeros((), result.dtype)

File ~/pycuda/pycuda/gpuarray.py:1394, in _array_like_helper(other_ary, dtype, order)
   1392         order = "C"
   1393 elif order == "K":
-> 1394     if other_ary.flags.c_contiguous or (other_ary.ndim <= 1):
   1395         order = "C"
   1396     elif other_ary.flags.f_contiguous:

AttributeError: 'float' object has no attribute 'flags'
@mitkotak mitkotak added the bug label 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