Skip to content
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

Simplify indexed ListTensor objects #336

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

pbrubeck
Copy link
Contributor

@pbrubeck pbrubeck commented Dec 30, 2024

When splitting mixed Forms, mixed Arguments get replaced by ListTensors of Zero and subspace Arguments of the form [0, ..., 0, v[0], ..., v[k], 0, ..., 0]. The resulting split Form would contain many instances of Indexed objects with this ListTensor, that could be simplified to either 0 or [v[0], ..., v[k]] -> v.

Previously, the simplification step was left as a task for the form compiler, but working with such complicated expressions often results in sub-optimal code generation. This PR addresses the following simplications at the UFL-level:

  1. Indexed(ListTensor[v0, ..., vk], (j,)) -> vj
  2. ListTensor(Indexed(v, FixedIndex(i)) for i in range(k)) -> v
  3. Restricted(ConstantValue) -> ConstantValue

As a consequence, splitting a bilinear Form with a block in the diagonal equal to zero produces an empty Form, losing all the information that the unsimplified Form carried around, such as the Arguments and the arity. This situation needs to be handled carefully as a special case. See firedrakeproject/firedrake#3947

With these simplifications, we can correctly estimate quadrature degrees for integrands that only depend on one component of the solution, thus lowering flop counts.

@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch 2 times, most recently from 80ab7ca to a7a7922 Compare December 30, 2024 03:36
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from a7a7922 to 0a0a4df Compare December 30, 2024 03:55
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 4dcc19a to 5db1162 Compare December 31, 2024 16:00
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 4fa252a to 7100560 Compare January 1, 2025 01:39
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 40d6f2f to 35509b8 Compare January 2, 2025 15:45
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 766da29 to e0c4e6a Compare January 4, 2025 19:41
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch 2 times, most recently from e09ca53 to 1356ae0 Compare January 7, 2025 01:36
@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 1356ae0 to bfa596d Compare January 7, 2025 06:15
@jhale
Copy link
Member

jhale commented Jan 8, 2025

This seems fine to me and thanks for the various modernisations added as well.

@pbrubeck pbrubeck force-pushed the pbrubeck/simplify-indexed branch from 33bd10d to bfa596d Compare January 8, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants