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

Make ZeroTangent() == 0 #607

Open
oxinabox opened this issue Mar 13, 2023 · 3 comments
Open

Make ZeroTangent() == 0 #607

oxinabox opened this issue Mar 13, 2023 · 3 comments

Comments

@oxinabox
Copy link
Member

oxinabox commented Mar 13, 2023

I feel like we can overload == for ZeroTangent()`
to do something like

==(::ZeroTangent, a) = iszero(a)

would also need to overload hash
since all things that are equal to zero in julia have the same hash, buit we can just call hash(0, h)

this would be useful for testhing some of the stuff i am working on to not AD things that don't appear in this function.

@mcabbott
Copy link
Member

For testing purposes, would it be sufficient to overload instead? That would avoid hash complications, and maybe invalidations.

Like here:
https://github.com/JuliaDiff/Diffractor.jl/pull/73/files#diff-fba4d4a7c64aacd9b1a662bca4487f3e849b43f09e65f6c8788a3f142b989f65R27-R32

@oxinabox
Copy link
Member Author

I want to test exact equality, though, not approximate.
And I want equality on tuples to work.
(isapprox isn't defined for tuples)

The hash complication is trivially resolved.
I hope there are not major invalidation issues, especially if we restrict it to Number. (or perhaps Union{Number,Array})
We did have to remove it from thunks, but that was unrestricted:
#524

@oxinabox
Copy link
Member Author

Not having this is causing issues for Diffractor
I look into this further soon and see what (if any) invalidation issues there are.

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

2 participants