Andreas,

I feel like some gpuarray methods (the one that override sub, mul, etc.)
have a non-intuitive behavior:

>>> import pycuda.autoinit
>>> from pycuda import gpuarray
>>> import numpy as np
>>> a_cpu = np.random.randn(2)
>>> a_gpu = gpuarray.to_gpu(a_cpu)
>>> # good
... print a_cpu - a_gpu.get()
[ 0.  0.]
>>> # bad results (no exception)
... print a_cpu - a_gpu
[[ 0.00797661  0.7765328 ] [ 0.79872256  0.61745578]]
>>> # exception
... print a_gpu - a_cpu
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File 
"/usr/lib/python2.5/site-packages/pycuda-0.93-py2.5-linux-x86_64.egg/pycuda/gpuarray.py",
line 248,
in __sub__
    if other == 0:
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()

--

How can we fix this properly? Should we inherit from ndarray?

Cheers,


-- 
Nicolas Pinto
Ph.D. Candidate, Brain & Computer Sciences
Massachusetts Institute of Technology, USA
http://web.mit.edu/pinto
_______________________________________________
PyCUDA mailing list
[email protected]
http://tiker.net/mailman/listinfo/pycuda_tiker.net

Reply via email to