Skip to content

Commit

Permalink
Use _return_type from Base, not from Core.Compiler (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
serenity4 authored Feb 25, 2025
1 parent 02e21ba commit 150c7a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRules"
uuid = "082447d4-558c-5d27-93f4-14fc19e9eca2"
version = "1.72.2"
version = "1.72.3"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
4 changes: 2 additions & 2 deletions src/rulesets/Base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end
# Path 2: This is roughly what `derivatives_given_output` is designed for, should be fast.

function may_bc_derivatives(::Type{T}, f::F, args::Vararg{Any,N}) where {T,F,N}
= Core.Compiler._return_type(derivatives_given_output, Tuple{T, F, map(_eltype, args)...})
= Core.Compiler.return_type(derivatives_given_output, Tuple{T, F, map(_eltype, args)...})
return isconcretetype(TΔ)
end

Expand Down Expand Up @@ -98,7 +98,7 @@ function may_bc_forwards(cfg::C, f::F, arg) where {C,F}
TA = _eltype(arg)
TA <: Real || return false
cfg isa RuleConfig{>:HasForwardsMode} && return true # allows frule_via_ad
TF = Core.Compiler._return_type(frule, Tuple{C, Tuple{NoTangent, TA}, F, TA})
TF = Core.Compiler.return_type(frule, Tuple{C, Tuple{NoTangent, TA}, F, TA})
return isconcretetype(TF) && TF <: Tuple
end

Expand Down
2 changes: 1 addition & 1 deletion src/rulesets/Base/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Works by seeing if the result of `derivatives_given_output(nothing, f, x)` can b
The method of `derivatives_given_output` usually comes from `@scalar_rule`.
"""
function _uses_input_only(f::F, ::Type{xT}) where {F,xT}
gT = Core.Compiler._return_type(derivatives_given_output, Tuple{Nothing, F, xT})
gT = Core.Compiler.return_type(derivatives_given_output, Tuple{Nothing, F, xT})
# Here we must check `<: Number`, to avoid this, the one rule which can return the `nothing`:
# ChainRules.derivatives_given_output("anything", exp, 1) == (("anything",),)
return isconcretetype(gT) && gT <: Tuple{Tuple{Number}}
Expand Down

2 comments on commit 150c7a1

@mcabbott
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/125824

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.72.3 -m "<description of version>" 150c7a1d70cd40d1dc73d463ee641e199732e968
git push origin v1.72.3

Please sign in to comment.