PytatoArrayContext.freeze: support container freezes - #158
Conversation
| See :meth:`ArrayContext.thaw`. | ||
| """ | ||
| if actx is not None and actx.supports_freezing_containers: |
There was a problem hiding this comment.
We should just deprecate these then (and expect all array contexts to support container freezes).
There was a problem hiding this comment.
Given that the freeze logic is specific to the containers (freeze is a single-dispatch function), deprecating this won't be possible.
There was a problem hiding this comment.
This should also be added to meshmode.dof_array then?
There was a problem hiding this comment.
As a side note, I really don't recall why we made this singledispatch-ed and can't think of a reason for it now. Anyone remember something?
There was a problem hiding this comment.
I don't. Array container freeze seems completely generic.
There was a problem hiding this comment.
I really don't recall why we made this singledispatch-ed and can't think of a reason for it now. Anyone remember something?
IIUC, array container initialization might be specific to the container type, and instead of forcing any constructor API we ask the container's writer to also provide a freeze. For example, DOFArray takes in a .array_context argument during initialization that must be set to None on getting frozen.
This should also be added to meshmode.dof_array then?
Yep!
There was a problem hiding this comment.
IIUC, array container initialization might be specific to the container type, and instead of forcing any constructor API we ask the container's writer to also provide a freeze. For example, DOFArray takes in a
.array_contextargument during initialization that must be set toNoneon getting frozen.
And using deserialize_container doesn't work because the template arg isn't necessarily frozen. Hm.. annoying..
Thanks for the reminder!
There was a problem hiding this comment.
Revisiting this: given the new logic, I think we ought to just deprecate the stand-alone freeze in favor of actx.freeze. (same for thaw) I don't see a strong rationale for keeping them.
There was a problem hiding this comment.
They do make it easy to just call freeze(container) as the actx is automatically inferred, if possible. If this is something that seems unnecessary, happy to deprecate it.
There was a problem hiding this comment.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9877625 to
a2d3debCompareinducer
commented
May 6, 2022
Discussed with @alexfikl a bit regarding the issue of how to set So the second-best solution we came up with is to deprecate How does that sound? |
a430a74 to
1bcd6c4Comparekaushikcfd
commented
May 9, 2022
Yep, this sounds like a cleaner approach. I've implemented the suggestions, however back-compatibility seems challenging (unachievable?). For ex. meshmode needs inducer/meshmode#327. |
inducer
commented
May 9, 2022
Yep, that's understood. But IMO |
70d61a2 to
7bef0f6Compare20b54ce to
7db55caCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| See :meth:`ArrayContext.thaw`. | ||
| """ | ||
| if actx is not None and actx.supports_freezing_containers: |
There was a problem hiding this comment.
Revisiting this: given the new logic, I think we ought to just deprecate the stand-alone freeze in favor of actx.freeze. (same for thaw) I don't see a strong rationale for keeping them.
inducer
left a comment
There was a problem hiding this comment.
Thanks! A few things to do here, but hopefully nothing onerous or disruptive. LGTM once these are take care of.
Uh oh!
There was an error while loading. Please reload this page.
| See :meth:`ArrayContext.thaw`. | ||
| """ | ||
| if actx is not None and actx.supports_freezing_containers: |
There was a problem hiding this comment.
Uh oh!
There was an error while loading. Please reload this page.
…ArrayContext.freeze` Co-authored-by: Andreas Kloeckner <inform@tiker.net>
inducer
commented
Jun 9, 2022
LGTM, thanks! Force-merging based on success of previous CI. |
Freezing across containers can potentially re-use common sub-expressions.
with_array_contextfor DOFArrays meshmode#327.Draft because: