-
Notifications
You must be signed in to change notification settings - Fork 11
Deprecate with_container_arithmetic's bcast_numpy_array arg #95
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
Conversation
|
cc @majosm (I think this would be worth a look once you're back) |
|
Not sure if I like the change in illinois-ceesd/mirgecom#514... requiring the application programmer to distinguish between numpy arrays of dtype float and object arrays containing floats seems less than ideal. Would it be enough to just forbid setting both |
|
@majosm: Yep, the interface won't be as brief as before, but I can see folks preferring Numpy over PyOpenCL in MIRGE-Com (for development purposes), as PyOpenCL arrays aren't quite fully implemented when it comes to features like broadcasting, non-contiguous copies, etc. (@thomasgibson took this route while prototyping some of his stuff). And, if we intend to support a Numpy-based array context, casting them into object arrays before using them for arithmetic is a deal-breaker for its implementation. |
|
I think an array context that just wraps As far as I can tell, it's not straightforward from looking at a numpy array in If there's an elegant way that gets us numpy array contexts and avoids the compat break, I'd be curious to hear about it. But as long as it an either-or between plain-numpy array contexts and slicker-looking broadcasting, I'll take the former, I think. |
cd81e92 to
7da8e1f
Compare
Is there a use case for |
Yep, if we use PytatoArrayContext for the project https://github.com/illinois-ceesd/drivers_y1-nozzle, we do see failures if |
|
About |
Ah, ok. Yeah, I can't really think of any way around this then. |
Passing both 'bcast_numpy_array' and '_bcast_actx_array_types' was
ill-defined. For example, in the case of an ArrayContext whose thawed
array type is np.ndarray the specification would contradict between
broadcasting the argument numpy_array to return an object array *OR*
peforming the operation with every leaf array.
Consider the example below,
(
- 'Foo: ArrayContainer' whose arithmetic routines are
generated by `with_container_arithmetic(bcast_numpy=True,
_bcast_actx_array_types=True)`
- 'actx: ArrayContextT' for whom `np.ndarray` is a valid thawed array
type.
)
Foo(DOFArray(actx, [38*actx.ones(3, np.float64)])) + np.array([3, 4, 5])
could be either of:
- array([Foo(DOFArray([array([41, 41, 41])])),
Foo(DOFArray([array([42, 42, 42])])),
Foo(DOFArray([array([43, 43, 43])]))]), OR,
- Foo(DOFArray(actx, array([41, 42, 43])))
7da8e1f to
dee59a7
Compare
Draft because