Skip to content

Commit

Permalink
simplify deferred failures (#2126)
Browse files Browse the repository at this point in the history
Co-authored-by: William Moses <wsmoses@cyclops.juliacomputing.io>
  • Loading branch information
wsmoses and William Moses authored Nov 27, 2024
1 parent 08bb15b commit 6a8e461
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Enzyme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,13 @@ code, as well as high-order differentiation.
rt = Compiler.primal_return_type(mode, FTy, tt)
A2 = A{rt}
if rt == Union{}
throw(ErrorException("Return type inferred to be Union{}. Giving up."))
rt = Nothing
end
else
@assert A isa DataType
rt = A
if rt == Union{}
throw(ErrorException("Return type inferred to be Union{}. Giving up."))
throw(ErrorException("Return type inferred to be Union{}. Giving up."))
end
end

Expand Down Expand Up @@ -841,7 +841,10 @@ code, as well as high-order differentiation.

if RT isa UnionAll
rt = Compiler.primal_return_type(mode, FT, tt)
rt = RT{rt}
if rt == Union{}
rt = Nothing
end
rt = RT{rt}
else
@assert RT isa DataType
rt = RT
Expand Down
2 changes: 1 addition & 1 deletion src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3262,7 +3262,7 @@ function primal_return_type_generator(world::UInt, source, self, @nospecialize(m
return new_ci
end

@eval @inline function primal_return_type(mode::Mode, ft::Type, tt::Type)
@eval Base.@assume_effects :removable :foldable :nothrow @inline function primal_return_type(mode::Mode, ft::Type, tt::Type)
$(Expr(:meta, :generated_only))
$(Expr(:meta, :generated, primal_return_type_generator))
end
Expand Down

2 comments on commit 6a8e461

@wsmoses
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register subdir="lib/EnzymeCore"

@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/120280

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 EnzymeCore-v0.8.7 -m "<description of version>" 6a8e46141cec083758adecffc218fca420b59ffc
git push origin EnzymeCore-v0.8.7

Please sign in to comment.