Sven Schreiber <[email protected]> writes: > Hi, > > I stumbled over the following behavior of pyopencl broadcasting; when I > run these equivalent operations in pure numpy and with pyopencl arrays, > numpy raises a ValueError while pyopencl does something surprising. > > <code> > CL = False # switch between pure numpy and pyopencl > > import numpy as n > flotype = n.float32 > > if CL == True: > import pyopencl as pcl > import pyopencl.array as cl_arr > > ctx = pcl.create_some_context() > qu = pcl.CommandQueue(ctx) > > def myzeros(shape): return cl_arr.zeros(qu,shape,dtype=flotype) > else: > myzeros = n.zeros > > check1 = myzeros((10,)) > print(check1) > check2 = myzeros((8,)) > print(check2) > check3 =myzeros((5,)) > print(check3) > check1 -= check3[0] * check2 > print(check1) > </code> > > The CL==True version produces: > <output> > [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] > [ 0. 0. 0. 0. 0. 0. 0. 0.] > [ 0. 0. 0. 0. 0.] > [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] > </output> > > while numpy says: > <output> > [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] > [ 0. 0. 0. 0. 0. 0. 0. 0.] > [ 0. 0. 0. 0. 0.] > Traceback (most recent call last): > File "pyopencl_bugtest.py", line 25, in <module> > check1 -= check3[0] * check2 > ValueError: operands could not be broadcast together with shapes (10) > (8) (10) > </output> > > I tend to think numpy is correct here. Or am I missing something? This > is with version 2013.1, my apologies if this behavior has already > changed since release.
Fixed in git, thanks for the report. Andreas
pgpPDgfqyaS8j.pgp
Description: PGP signature
_______________________________________________ PyOpenCL mailing list [email protected] http://lists.tiker.net/listinfo/pyopencl
