# [GT4Py] Concat where cleanup & merge __WORKING DOCUMENT__ - Shaped by: @tehrengruber - Appetite (FTEs, weeks): - Developers: @tehrengruber <!-- Filled in at the betting table unless someone is specifically required here --> ## Problem The `concat_where` branch is now being used in icon4py main, but it is not yet merged into GT4Py main. - Missing `UnitTest`s for several passes - ExpandLibraryFunctions - InferDomainOps - NestConcatWheres - TransformConcatWhere - Expression duplication in `NestConcatWhere` pass - General cleanup & review process ## Appetite 2 weeks ## Solution - Split PR into 3 sub PRs - Frontend - Embedded - Toolchain - Write unit tests - Solve remaining list of small todos & open questions - [ ] remove https://github.com/GridTools/gt4py/pull/1863 again - [ ] `0 < IDim < 10` should throw an error as this is not supported in embedded. - [ ] lower frontend `concat_where(domain, (a, b), (c, d))` into `concat_where(domain, (a, b), (c, d))` instead of `(concat_where(domain, a, c), concat_where(domain, b, d))`. See todo here: https://github.com/GridTools/gt4py/pull/1713/files#diff-b7168b25e2345866d9c46bff110792950fe8f5be82878ec8cf8fcdafc26e22ebR417 - [ ] Cleanup and document `keep_existing_domains` flag of `infer_domain` pass - [ ] Investigate and fix this issue: https://github.com/GridTools/gt4py/pull/1713/files#diff-9b003e0c6a1068fc9995e928ce2ddf38facbd2eadef785bcb9aa070ed837469dR381 - [ ] Why is this disabled again? https://github.com/GridTools/gt4py/pull/1713/files#diff-9a135e545740de71a5df9d815eb26618e5924aa8de8c8a281c7c07c9a7343659R104 - [ ] Figure out when and why to constant fold here https://github.com/GridTools/gt4py/pull/1713/files#diff-7e41301b2fee01eee6191c5f4fd0c172f83666fe6bba68da8317465bd51b586dR106. Document why. - [ ] Test cases for `concat_where(IDim < 10, (field_i, field_ij), (field_i2, field_ij2))`. See https://github.com/GridTools/gt4py/pull/1713/files#diff-6ee794b4f2022b873e2c73095c094288cac94cc0d8b9b145fa373458699ddcdbR39. Maybe don't implement in first version, but at tests + proper error would be nice. - [ ] Embedded https://github.com/SF-N/gt4py/pull/14. Infinite domains do not work and require a function field or alike. ## Rabbit holes ## No-gos <!-- Anything specifically excluded from the concept: functionality or use cases we intentionally aren’t covering to fit the ## appetite or make the problem tractable --> ## Progress <!-- Don't fill during shaping. This area is for collecting TODOs during building. As first task during building add a preliminary list of coarse-grained tasks for the project and refine them with finer-grained items when it makes sense as you work on them. --> - [x] Task 1 ([PR#xxxx](https://github.com/GridTools/gt4py/pulls)) - [x] Subtask A - [x] Subtask X - [ ] Task 2 - [x] Subtask H - [ ] Subtask J - [ ] Discovered Task 3 - [ ] Subtask L - [ ] Subtask S - [ ] Task 4 ## Notes 15.04 Topic: How to continue with concat_where? Idea for embedded concat_where: ``` def concat_where(domain, a, b): if isinstance(domain, UnionSet): return concat_where(domain.first, a, concat_where(domain.second, a, b)) # maybe wrong semantic ... ``` This way we don't need to support any fancy operations between unions of sets that are not continuous.