Skip to content

Commit

Permalink
Expand unthunk-tangent with more methods (#28)
Browse files Browse the repository at this point in the history
* Expand unthunk-tangent to more methods

* Fix

* Bump to 0.2.6
  • Loading branch information
pxl-th authored Jan 20, 2025
1 parent f9bf0e3 commit a4d77ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ZygoteRules"
uuid = "700de1a5-db45-46bc-99cf-38207098b444"
version = "0.2.5"
version = "0.2.6"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
8 changes: 7 additions & 1 deletion src/adjoint.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MacroTools
using MacroTools: @q, combinedef
using ChainRulesCore: AbstractZero
using ChainRulesCore: AbstractZero, AbstractThunk, @non_differentiable

function named(arg)
if isexpr(arg, :(::)) && length(arg.args) == 1
Expand Down Expand Up @@ -37,6 +37,12 @@ function unthunk_tangent end
@inline unthunk_tangent(x) = x
@inline unthunk_tangent(x::Tuple) = map(unthunk_tangent, x)
@inline unthunk_tangent(x::NamedTuple) = map(unthunk_tangent, x)
@inline unthunk_tangent(x::AbstractThunk) = wrap_chainrules_output(unthunk(x))
@inline unthunk_tangent(x::NTuple{N,<:Number}) where N = x
@inline unthunk_tangent(x::AbstractArray{<:Number,N}) where N = x
@inline unthunk_tangent(x::AbstractArray) = map(unthunk_tangent, x)
unthunk_tangent(d::IdDict) = IdDict([unthunk_tangent(k) => unthunk_tangent(v) for (k, v) in d])
@non_differentiable unthunk_tangent(::IdDict)


function gradm(ex, mut = false, keepthunks = false)
Expand Down

2 comments on commit a4d77ab

@ToucheSir
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/123319

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 v0.2.6 -m "<description of version>" a4d77ab1f23b05f461acd37fd5a17540a330cd0b
git push origin v0.2.6

Please sign in to comment.