-
Notifications
You must be signed in to change notification settings - Fork 23
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
Freeze constant arrays #354
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,6 +232,12 @@ class _FromGroupPickData(Generic[ArrayT]): | |
from_element_indices: ArrayT | ||
is_surjective: bool | ||
|
||
@keyed_memoize_method(key=lambda actx: type(actx)) | ||
def indexed_dof_pick_lists(self, actx): | ||
kaushikcfd marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain why this is needed? I would have figured that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is computing |
||
assert actx.permits_advanced_indexing | ||
return actx.freeze( | ||
actx.thaw(self.dof_pick_lists)[actx.thaw(self.dof_pick_list_indices)]) | ||
|
||
# }}} | ||
|
||
|
||
|
@@ -356,7 +362,7 @@ def __init__(self, | |
# {{{ _resample_matrix | ||
|
||
@keyed_memoize_method(key=lambda actx, to_group_index, ibatch_index: | ||
(to_group_index, ibatch_index)) | ||
(type(actx), to_group_index, ibatch_index)) | ||
def _resample_matrix(self, actx: ArrayContext, to_group_index: int, | ||
ibatch_index: int): | ||
import modepy as mp | ||
|
@@ -435,7 +441,8 @@ def _resample_point_pick_indices(self, to_group_index: int, ibatch_index: int, | |
return result | ||
|
||
@keyed_memoize_method(lambda actx, to_group_index, ibatch_index, | ||
tol_multiplier=None: (to_group_index, ibatch_index, tol_multiplier)) | ||
tol_multiplier=None: (type(actx), to_group_index, | ||
ibatch_index, tol_multiplier)) | ||
def _frozen_resample_point_pick_indices(self, actx: ArrayContext, | ||
to_group_index: int, ibatch_index: int, | ||
tol_multiplier: Optional[float] = None): | ||
|
@@ -736,8 +743,7 @@ def group_pick_knl(is_surjective: bool): | |
grp_ary_contrib = ary[fgpd.from_group_index][ | ||
_reshape_and_preserve_tags( | ||
actx, from_element_indices, (-1, 1)), | ||
actx.thaw(fgpd.dof_pick_lists)[ | ||
actx.thaw(fgpd.dof_pick_list_indices)] | ||
actx.thaw(fgpd.indexed_dof_pick_lists(actx)) | ||
] | ||
|
||
if not fgpd.is_surjective: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not completely sure if this is the right object to maintain the memoization dict. (Lmk if you think something's not ideal here)