Skip to content

Commit

Permalink
More unthunking in ∇chunk (#180)
Browse files Browse the repository at this point in the history
* Update utils.jl

* version 0.4.5
  • Loading branch information
mcabbott authored Jan 4, 2025
1 parent 204b958 commit eb5934a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLUtils"
uuid = "f1d291b0-491e-4a28-83b9-f70985020b54"
authors = ["Carlo Lucibello <[email protected]> and contributors"]
version = "0.4.4"
version = "0.4.5"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ end
@non_differentiable _partition_idxs(::Any...)

# Similar to ∇eachslice https://github.com/JuliaDiff/ChainRules.jl/blob/8108a77a96af5d4b0c460aac393e44f8943f3c5e/src/rulesets/Base/indexing.jl#L77
function ∇chunk(dys, x, idxs, vd::Val{dim}) where {dim}
function ∇chunk(dys_raw, x, idxs, vd::Val{dim}) where {dim}
dys = unthunk.(unthunk(dys_raw)) # https://github.com/FluxML/Zygote.jl/pull/966#issuecomment-2569227272
i1 = findfirst(dy -> !(dy isa AbstractZero), dys)
if i1 === nothing # all slices are Zero!
return _zero_fill!(similar(x, float(eltype(x))))
Expand Down

2 comments on commit eb5934a

@CarloLucibello
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/122393

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

Please sign in to comment.