This repository has been archived by the owner on Mar 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
Extend flattened_tup_chain
capability for diagnostics, update VariableTemplates
#1929
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
charleskawczynski
force-pushed
the
ck/variable_templates
branch
from
January 15, 2021 17:01
e63207a
to
592be54
Compare
kpamnany
approved these changes
Jan 15, 2021
charleskawczynski
force-pushed
the
ck/variable_templates
branch
from
January 15, 2021 19:01
592be54
to
b0c5231
Compare
bors r+ |
bors bot
added a commit
that referenced
this pull request
Jan 15, 2021
1929: Extend `flattened_tup_chain` capability for diagnostics, update VariableTemplates r=charleskawczynski a=charleskawczynski ### Description This PR: - Removes the CPU `getindex(x, i::Int)` fallback (`# Somehow needed for GPU...` was basically a TODO), so our CPU/GPU failures should be more nicely in sync. Interestingly, the `getindex(x, i::Int)` was hit on the GPU but worked in certain situations and not others. I've accordingly wrapped indexes with `Val` (in EDMF-related files) - Simplifies the nested intertwined `getproperty`/`getindex` flow control, which previously used `if-else` and now only uses dispatch - Split some methods to avoid `isa` calls in `getindex` And the new feature: - `flattened_tup_chain` now has two modes of operation: one that retains arrays (`RetainArr`) and flatten arrays (`FlattenArr`). - `flattened_named_tuple` also has this option. Here is a demo (where `v::Vars` and `vars_state(...) = @vars(x::SVector{3, FT})`): ```julia fnt = flattened_named_tuple(v, RetainArr()) @test fnt.x == Float32[1.0, 2.0, 3.0] fnt = flattened_named_tuple(v, FlattenArr()) @test fnt.x_1 == 1.0 @test fnt.x_2 == 2.0 @test fnt.x_3 == 3.0 ``` I've kept the old functionality (with `RetainArr`), as this may be useful if we want to automate traversing variables (e.g., #1921, in which case we'll need to work with the vectors) This also flattens the single stack diagnostics, which will allow us to more easily automate the conversion between `dons_arr` and `diag_arr` cc @ilopezgp. This also cleans up some of the edmf QA script. ⏳ Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
Build failed: |
charleskawczynski
force-pushed
the
ck/variable_templates
branch
from
January 16, 2021 00:52
b0c5231
to
38ee22b
Compare
bors r+ |
4 tasks
bors bot
added a commit
that referenced
this pull request
Jan 17, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 18, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 18, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 18, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 19, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 19, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
bors bot
added a commit
that referenced
this pull request
Jan 25, 2021
1931: Fix NamedTuple keys, add error handling r=charleskawczynski a=charleskawczynski ### Description After #1929, there is some mismatch with the keys and values returned from `flattened_named_tuple` and thus `single_stack_diagnostics` (e.g., IIRC, mixing length). cc @yairchn @ilopezgp. This PR should fix this mismatch. Specifically, adding ```julia length(keys_) == length(vals) || error("key-value mismatch") ``` to `flattened_named_tuple` errors on master due to improper handling of `SHermitianCompact` and `Diagonal` arrays. This required some changes / additions to `flattened_nt_vals`. Co-authored-by: Charles Kawczynski <kawczynski.charles@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR:
getindex(x, i::Int)
fallback (# Somehow needed for GPU...
was basically a TODO), so our CPU/GPU failures should be more nicely in sync. Interestingly, thegetindex(x, i::Int)
was hit on the GPU but worked in certain situations and not others. I've accordingly wrapped indexes withVal
(in EDMF-related files)getproperty
/getindex
flow control, which previously usedif-else
and now only uses dispatchisa
calls ingetindex
And the new feature:
flattened_tup_chain
now has two modes of operation: one that retains arrays (RetainArr
) and flatten arrays (FlattenArr
).flattened_named_tuple
also has this option. Here is a demo (wherev::Vars
andvars_state(...) = @vars(x::SVector{3, FT})
):I've kept the old functionality (with
RetainArr
), as this may be useful if we want to automate traversing variables (e.g., #1921, in which case we'll need to work with the vectors)This also flattens the single stack diagnostics, which will allow us to more easily automate the conversion between
dons_arr
anddiag_arr
cc @ilopezgp.This also cleans up some of the edmf QA script. ⏳