>>> a = cla.to_device(cq, np.ones(3))
>>> b = cla.to_device(cq, np.ones(()))
>>> a
cl.Array([1., 1., 1.])
>>> b
cl.Array(1.)
>>> a * b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/shared/home/kgk2/pack/virtual_envs/emirge/pyopencl/pyopencl/array.py", line 1161, in __mul__
self._elwise_multiply(result, self, other))
File "/shared/home/kgk2/pack/virtual_envs/emirge/pyopencl/pyopencl/array.py", line 183, in kernel_runner
knl = kernel_getter(*args, **kwargs)
File "/shared/home/kgk2/pack/virtual_envs/emirge/pyopencl/pyopencl/array.py", line 897, in _elwise_multiply
assert out.shape == b.shape
It's somewhat straightforward to hack this in, but it's also kind of annoying: It's not like we'll be teaching the array anything about broadcasting in general, just the device scalar * array case.
Raised by @kaushikcfd here: https://github.com/inducer/arraycontext/issues/49#issuecomment-869266944
Example: