Skip to content

Make length of Partials known at compile time in ForwardDiff overloads #727

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

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

Conversation

jClugstor
Copy link
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@ChrisRackauckas
Copy link
Member

JET test it?

@jClugstor
Copy link
Member Author

using LinearSolve
using ForwardDiff
using Test
using JET

function h(p)
    (A=[p[1] p[2]+1 p[2]^3;
            3*p[1] p[1]+5 p[2]*p[1]-4;
            p[2]^2 9*p[1] p[2]],
        b=[p[1] + 1, p[2] * 2, p[1]^2])
end

A, b = h([ForwardDiff.Dual(5.0, 1.0, 0.0), ForwardDiff.Dual(5.0, 0.0, 1.0)])

prob = LinearProblem(A, b)

cache = init(prob)

solve!(cache)

ext = Base.get_extension(LinearSolve, :LinearSolveForwardDiffExt)

@test_opt ext.linearsolve_dual_solution([1.0, 1.0, 1.0], [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], cache)

This passes now.

Without this change there is indeed a runtime dispatch.

There are also a bunch of runtime dispatches for an overall solve!(cache), so I can try to work on those as well.

@ChrisRackauckas
Copy link
Member

Okay, but you still didn't add that to the JET tests.

@oscardssmith oscardssmith self-assigned this Aug 18, 2025
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.

3 participants