Skip to content

Conversation

@moble
Copy link
Contributor

@moble moble commented Sep 29, 2025

Currently, there are rules for hypot(x) and hypot(x, y), but Base defines hypot(x, y, xs...), which is not handled by ChainRules. The two-argument case is in fastmath_able, but Base.FastMath only supports the two-argument method, so this PR adds separate forward and reverse rules specifically for 3 arguments, with a Vararg on the end, to handle the remaining possibilities. These new rules are just mild generalizations of the two-argument rules.

Co-authored-by: David Müller-Widmann <[email protected]>
@moble
Copy link
Contributor Author

moble commented Sep 30, 2025

Thanks for the suggestions @devmotion. The CI errors seems to be consistent with, e.g., the most recently merged commit. But the new hypot tests in base.jl seem to have passed.

test_rrule(merge, (; a=1.0), (; a=2.0))
end

@testset "hypot(x, y, z, xs...)" begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add tests with mixed Real/Complex inputs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to test mixed inputs. The new tests are passing; CI failures are the same as before.

@devmotion devmotion merged commit 2dad6a7 into JuliaDiff:main Sep 30, 2025
5 of 10 checks passed
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