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

Improve fused_assemble design #15

Open
charleskawczynski opened this issue Apr 11, 2024 · 1 comment
Open

Improve fused_assemble design #15

charleskawczynski opened this issue Apr 11, 2024 · 1 comment

Comments

@charleskawczynski
Copy link
Member

charleskawczynski commented Apr 11, 2024

Right now, fused_assemble generates code like:

pairs = ()
  pairs = (pairs..., :(@. x += 1))
  for i in 1:2
    pairs = (pairs..., :(@. x += 2))
    pairs = (pairs..., :(@. x += 3))
  end
end

But this is type-unstable because the type of pairs changes across the loop. We could instead lower this to:

pairs = ()
  pairs = (pairs..., :(@. x += 1))
  pairs = (pairs..., Iterators.flatmap(1:2) do i
    (:(@. x += 2), :(@. x += 3))
  end
end

which the compiler may have a chance at inferring.

One consideration is: what if we have if-blocks inside? It should work with Union-splitting, but this approach might be problematic if there are runtime checks.

@charleskawczynski
Copy link
Member Author

Also, if check_restrictions passes for simple internals, we can lower to a simple tuple(...) result.

@charleskawczynski charleskawczynski changed the title Improve fused_pairs_flexible design Improve fused_assemble design May 1, 2024
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

No branches or pull requests

1 participant