Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
pxl-th committed Dec 29, 2024
1 parent 6e23e61 commit 672698d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/rulesets/Base/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,17 @@ end
Val(3);
check_inferred=(VERSION >= v"1.7"),
)

# eachslice: Make sure pulling back an array of thunks unthunks them and does not return all zeros.
x = ones(Float32, 3)
Δ = ones(Float32, 1)
_, norm_back = ChainRules.rrule(norm, x)
dx = norm_back(Δ)[2]
@test dx isa AbstractThunk

x = ones(Float32, 3, 1)
_, eachcol_back = ChainRules.rrule(eachcol, x)
Δ2 = [dx]
dx2 = eachcol_back(Δ2)[2]
@test all(dx2 .≉ 0f0)
end

0 comments on commit 672698d

Please sign in to comment.