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

Define a bunch of zero_tangents that should just NoTangent #662

Merged
merged 4 commits into from
Feb 8, 2024

Conversation

oxinabox
Copy link
Member

@oxinabox oxinabox commented Feb 8, 2024

I do vaguely wonder if we should just preemptively walk things and if we don't find an AbstractFloat element always return NoTangent.
But for now I am just marking a bunch of stuff that has no tangent space as zero_tangent(x)=NoTangent()

Also fixes AbstractDict though we have never properly implemented dict support in AD.

@oxinabox oxinabox requested a review from oscardssmith February 8, 2024 08:03
src/tangent_types/abstract_zero.jl Outdated Show resolved Hide resolved
src/tangent_types/abstract_zero.jl Outdated Show resolved Hide resolved
zero_tangent(::Core.Compiler.AbstractInterpreter) = NoTangent()
zero_tangent(::Core.Compiler.InstructionStream) = NoTangent()
zero_tangent(::Core.CodeInfo) = NoTangent()
zero_tangent(::Core.MethodInstance) = NoTangent()
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
zero_tangent(::Core.MethodInstance) = NoTangent()
zero_tangent(::Core.MethodInstance) = NoTangent()

test/tangent_types/abstract_zero.jl Outdated Show resolved Hide resolved
test/tangent_types/abstract_zero.jl Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (0385ea8) 94.26% compared to head (a105ba9) 93.80%.

Files Patch % Lines
src/tangent_types/abstract_zero.jl 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #662      +/-   ##
==========================================
- Coverage   94.26%   93.80%   -0.47%     
==========================================
  Files          15       15              
  Lines         977      985       +8     
==========================================
+ Hits          921      924       +3     
- Misses         56       61       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

oxinabox and others added 2 commits February 8, 2024 16:06
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Comment on lines 187 to 188
zero_tangent(Dict{Int, Float64}(1=>2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int, Float64}())
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
zero_tangent(Dict{Int, Float64}(1=>2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int, Float64}())
zero_tangent(Dict{Int,Float64}(1 => 2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int,Float64}()),

Comment on lines 191 to 192
zero_tangent(Base.PersistentDict(1=>2.4)),
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int, Float64}())
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
zero_tangent(Base.PersistentDict(1=>2.4)),
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int, Float64}())
zero_tangent(Base.PersistentDict(1 => 2.4)),
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int,Float64}()),

Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int, Float64}())
)


Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change

Comment on lines +187 to +188
zero_tangent(Dict{Int, Float64}(1 => 2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int, Float64}())
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
zero_tangent(Dict{Int, Float64}(1 => 2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int, Float64}())
zero_tangent(Dict{Int,Float64}(1 => 2.4)),
Tangent{Dict{Int,Float64}}(Dict{Int,Float64}()),

if isdefined(Base, :PersistentDict)
@test ==(
zero_tangent(Base.PersistentDict(1 => 2.4)),
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int, Float64}())
Copy link
Contributor

Choose a reason for hiding this comment

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

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int, Float64}())
Tangent{Base.PersistentDict{Int,Float64}}(Dict{Int,Float64}()),

@oxinabox oxinabox merged commit 6a8c3c2 into main Feb 8, 2024
20 of 28 checks passed
@oxinabox oxinabox deleted the ox/donot_zero branch February 8, 2024 10:59
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.

1 participant