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

Support ifelse #94

Merged
merged 25 commits into from
May 24, 2024
Merged

Support ifelse #94

merged 25 commits into from
May 24, 2024

Conversation

adrhill
Copy link
Owner

@adrhill adrhill commented May 22, 2024

Quick prototype to discuss #90.

Tests pass on 1.10, I'll fix 1.6 in case this is useful.

Major changes:

  • Dual is now a Real, not an AbstractTracer
  • Add support for ifelse on AbstractTracer
  • Split overloading functions

@codecov-commenter
Copy link

codecov-commenter commented May 22, 2024

Codecov Report

Attention: Patch coverage is 75.51020% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 80.58%. Comparing base (1f85b58) to head (cc0433a).
Report is 1 commits behind head on main.

Files Patch % Lines
src/conversion.jl 36.00% 16 Missing ⚠️
src/overload_ifelse.jl 63.63% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
+ Coverage   79.63%   80.58%   +0.94%     
==========================================
  Files          17       18       +1     
  Lines         712      757      +45     
==========================================
+ Hits          567      610      +43     
- Misses        145      147       +2     

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

@gdalle
Copy link
Collaborator

gdalle commented May 23, 2024

The test failures you're seeing here are an example of comparison method ambiguities #95 (comment)

@gdalle gdalle mentioned this pull request May 23, 2024
@gdalle gdalle linked an issue May 23, 2024 that may be closed by this pull request
@adrhill
Copy link
Owner Author

adrhill commented May 23, 2024

Very odd and generic error on 1.6. Can ifelse not be overloaded here?

ERROR: LoadError: LoadError: cannot add methods to a builtin function
Stacktrace:
  [1] top-level scope
    @ ~/work/SparseConnectivityTracer.jl/SparseConnectivityTracer.jl/src/overload_ifelse.jl:3
  [2] include(mod::Module, _path::String)
    @ Base ./Base.jl:384
  [3] include(x::String)
    @ SparseConnectivityTracer ~/work/SparseConnectivityTracer.jl/SparseConnectivityTracer.jl/src/SparseConnectivityTracer.jl:1
  [4] top-level scope
    @ ~/work/SparseConnectivityTracer.jl/SparseConnectivityTracer.jl/src/SparseConnectivityTracer.jl:27

L3 is:

function Base.ifelse(::T, x, y) where {T<:SimpleTracer}
    size(x) != size(y) &&
        throw(DimensionMismatch("Outputs sizes of `ifelse` arguments don't match in size."))
    return output_union(x, y)
end

@gdalle
Copy link
Collaborator

gdalle commented May 23, 2024

No clue, never encountered this

src/overload_ifelse.jl Outdated Show resolved Hide resolved
src/overload_ifelse.jl Outdated Show resolved Hide resolved
src/overload_ifelse.jl Outdated Show resolved Hide resolved
src/overload_ifelse.jl Outdated Show resolved Hide resolved
src/overload_ifelse.jl Outdated Show resolved Hide resolved
test/test_gradient.jl Outdated Show resolved Hide resolved
test/test_gradient.jl Show resolved Hide resolved
src/overload_ifelse.jl Show resolved Hide resolved
test/test_connectivity.jl Outdated Show resolved Hide resolved
test/test_gradient.jl Outdated Show resolved Hide resolved
@adrhill adrhill merged commit 317d917 into main May 24, 2024
4 checks passed
@adrhill adrhill deleted the ah/ifelse branch May 24, 2024 19:38
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.

Global sparsity detection with control flow
3 participants