Conversation
alexfikl
commented
Jun 28, 2021
Is the "not device scalar" case useful? In the general case, |
kaushikcfd
commented
Jun 28, 2021
If the broadcasting for any of the leaf arrays is illegal, we would see an error, which IMO is a reasonable user experience. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| else: | ||
| raise ValueError(msg)""") | ||
| gen(f"return cls({zip_init_args})") | ||
| if _cls_has_array_context_attr: |
There was a problem hiding this comment.
This should get its own flag, defaulted to the same value as bcast_number.
| raise ValueError(msg)""") | ||
| gen(f"return cls({zip_init_args})") | ||
| if _cls_has_array_context_attr: | ||
| gen("if isinstance(arg2," |
There was a problem hiding this comment.
Ordering here matters a great deal. (Maybe there should be a comment stating this.) These cases should be sorted from most likely to least. Is this the second-most-likely case?
There was a problem hiding this comment.
IMO, this use-case would come just after host-scalars, as implemented in 93013c9.
| gen(f""" | ||
| if {bool(outer_bcast_type_names)}: # optimized away | ||
| if isinstance(arg2, {tup_str(outer_bcast_type_names)}): |
There was a problem hiding this comment.
This should also work (and be tested) for the reverse operators.
Uh oh!
There was an error while loading. Please reload this page.
alexfikl
left a comment
There was a problem hiding this comment.
Looks good to me!
Just left a very small nitpick.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Alex Fikl <alexfikl@gmail.com>
replaced with only if Co-authored-by: Alex Fikl <alexfikl@gmail.com>
| def get_array_types(self): | ||
| """ | ||
| Returns a :class:`tuple` of types that are valid base array classes | ||
| the context can operate on. | ||
| """ | ||
| return () |
There was a problem hiding this comment.
- I think this could be an attribute, to avoid the function call overhead. (If you need non-global import to set it, set it in the constructor.)
- I think documenting this is probably OK.
- Would it be sensible to only allow one type here, to avoid the splat above?
There was a problem hiding this comment.
Done. 9255f22
Would it be sensible to only allow one type here, to avoid the splat above?
I think there is some value in keeping it tuple, default value is much nicer since the only intent is to perform type checking using it + also accounts for the slightest of chances that an array context might not have a single base array type.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if bcast_actx_array_type: | ||
| all_outer_bcast_type_names = ( | ||
| outer_bcast_type_names | ||
| + ("*arg1.array_context.get_array_types()",)) | ||
| else: | ||
| all_outer_bcast_type_names = outer_bcast_type_names |
There was a problem hiding this comment.
- Move this closer to the usage site.
- Make this produce a tuple that's either empty or has the actx array type(s) in it. Add both together in the argument of
tup_str.
(Same below for reverse.)
inducer
commented
Jul 5, 2021
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
Co-authored-by: Andreas Kloeckner <andreask@illinois.edu>
inducer
left a comment
There was a problem hiding this comment.
Thanks! Just a few more minor things, then this is ready to go.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
inducer
commented
Jul 6, 2021
Unsubscribing... @-mention or request review once it's ready for a look or needs attention. |
Closes#49.