Title: Broadcasting rules distinguish between host scalar and device scalars · Issue #49 · inducer/arraycontext · GitHub
Open Graph Title: Broadcasting rules distinguish between host scalar and device scalars · Issue #49 · inducer/arraycontext
X Title: Broadcasting rules distinguish between host scalar and device scalars · Issue #49 · inducer/arraycontext
Description: Consider this script: actx = _acf() @with_container_arithmetic( bcast_obj_array=True, bcast_numpy_array=True, rel_comparison=True, _cls_has_array_context_attr=True) @dataclass_array_container @dataclass(frozen=True) class Foo: u: DOFArra...
Open Graph Description: Consider this script: actx = _acf() @with_container_arithmetic( bcast_obj_array=True, bcast_numpy_array=True, rel_comparison=True, _cls_has_array_context_attr=True) @dataclass_array_container @data...
X Description: Consider this script: actx = _acf() @with_container_arithmetic( bcast_obj_array=True, bcast_numpy_array=True, rel_comparison=True, _cls_has_array_context_attr=True) @dataclass_array_container @data...
Opengraph URL: https://github.com/inducer/arraycontext/issues/49
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Broadcasting rules distinguish between host scalar and device scalars","articleBody":"Consider this script:\r\n```python\r\nactx = _acf()\r\n\r\n@with_container_arithmetic(\r\n bcast_obj_array=True,\r\n bcast_numpy_array=True,\r\n rel_comparison=True,\r\n _cls_has_array_context_attr=True)\r\n@dataclass_array_container\r\n@dataclass(frozen=True)\r\nclass Foo:\r\n u: DOFArray\r\n\r\nfoo = Foo(DOFArray(actx, (actx.zeros(3, dtype=np.float64) + 41, )))\r\n\r\nprint(foo) # prints: Foo(u=DOFArray((cl.Array([41., 41., 41.]),)))\r\nprint(foo + 1) # prints: Foo(u=DOFArray((cl.Array([42., 42., 42.]),)))\r\nprint(foo + actx.from_numpy(np.ones(()))) # ERROR! 😲\r\n```\r\n\r\nI don't see a good reason why we don't support this.\r\n\r\nI think we should also go a step ahead and make sure that we broadcast every cl.Array to be added (if legal) with all the leaf arrays of the array container. One way I could see this working is if every `ArrayContext` comes with a `ARRAY_TYPE` static, frozen attribute which gives us a hint to broadcast to all successive arrays.","author":{"url":"https://github.com/kaushikcfd","@type":"Person","name":"kaushikcfd"},"datePublished":"2021-06-26T19:26:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/49/arraycontext/issues/49"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:40cc8cc0-2b96-1d8b-1d83-90f8a23c26ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BCB4:33952:2DF9315:401B913:6A4F69C5 |
| html-safe-nonce | 095e59fe2f25e75ec7f6031315ff9b14781d96bafd5d3cb22d086de18ee2c112 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQ0I0OjMzOTUyOjJERjkzMTU6NDAxQjkxMzo2QTRGNjlDNSIsInZpc2l0b3JfaWQiOiI2OTIyMDc1NTU3MjUwMTY1MTkwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b5dee830bba0ea6bbd1d6abb3e83215784096c3dace228ea69ececb31601ed5a |
| hovercard-subject-tag | issue:930779632 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/inducer/arraycontext/49/issue_layout |
| twitter:image | https://opengraph.githubassets.com/79baa99b19b0397f9655979936064954e29132299185c961c5c637561bf0f807/inducer/arraycontext/issues/49 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/79baa99b19b0397f9655979936064954e29132299185c961c5c637561bf0f807/inducer/arraycontext/issues/49 |
| og:image:alt | Consider this script: actx = _acf() @with_container_arithmetic( bcast_obj_array=True, bcast_numpy_array=True, rel_comparison=True, _cls_has_array_context_attr=True) @dataclass_array_container @data... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kaushikcfd |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/inducer/arraycontext git https://github.com/inducer/arraycontext.git |
| octolytics-dimension-user_id | 352067 |
| octolytics-dimension-user_login | inducer |
| octolytics-dimension-repository_id | 364716587 |
| octolytics-dimension-repository_nwo | inducer/arraycontext |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 364716587 |
| octolytics-dimension-repository_network_root_nwo | inducer/arraycontext |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width