Skip to content

Commit

Permalink
adjoint test may work
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed May 12, 2021
1 parent 0e5648b commit ccd9dcf
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/rulesets/Base/mapreduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,10 @@
# Adjoint -- like PermutedDimsArray this may actually be used
xa = adjoint(rand(T,4,4))
test_rrule(prod, xa rand(T,4,4))
@test_skip test_rrule(prod, xa rand(T,4,4), fkwargs=(dims=2,)) # seems broken?
#=
xa = randn(3,3)'
Zygote.gradient(x -> sum(prod(x,dims=1)), xa)[1]
ForwardDiff.gradient(x -> sum(prod(x,dims=1)), xa)
Zygote.gradient(x -> sum(prod(x,dims=1)), Matrix(xa))[1]
# These all agree, so the fault is in the testing, somehow.
=#
test_rrule(prod, xa rand(T,4,4), fkwargs=(dims=2,))
@test unthunk(rrule(prod, adjoint(rand(T,3,3)))[2](1.0)[2]) isa Matrix
@test unthunk(rrule(prod, adjoint(rand(T,3,3)), dims=1)[2](ones(1,3))[2]) isa Matrix

# Diagonal -- a stupid thing to do, product of zeros! Shouldn't be an error though:
@test iszero(unthunk(rrule(prod, Diagonal(rand(T,3)))[2](1.0)[2]))
@test iszero(unthunk(rrule(prod, Diagonal(rand(T,3)), dims=1)[2](ones(1,3))[2]))
Expand Down

0 comments on commit ccd9dcf

Please sign in to comment.