Skip to content

Commit

Permalink
skip Yota on nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Jul 28, 2023
1 parent 545150d commit 26b0134
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions test/destructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ end
# Diffractor error in perform_optic_transform
end

VERSION < v"1.9-" && @testset "using Yota" begin
VERSION < v"1.10-" && @testset "using Yota" begin
@test Yota_gradient(m -> destructure(m)[1][1], m1)[1] == [1,0,0]
@test Yota_gradient(m -> destructure(m)[1][2], m2)[1] == ([0,1,0], [0,0,0])
@test Yota_gradient(m -> destructure(m)[1][3], (m1, m1))[1] == ([0,0,1], nothing)
Expand Down Expand Up @@ -175,7 +175,7 @@ end
# Zygote.@adjoint Tangent{T,B}(x::NamedTuple) where {T,B<:NamedTuple} = Tangent{T,B}(x), dx -> (dx,)
end

VERSION < v"1.9-" && @testset "using Yota" begin
VERSION < v"1.10-" && @testset "using Yota" begin
re1 = destructure(m1)[2]
@test Yota_gradient(x -> re1(x)[1], rand(3))[1] == [1,0,0]
re2 = destructure(m2)[2]
Expand Down
17 changes: 10 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Optimisers
using ChainRulesCore, Functors, StaticArrays, Zygote, Yota
using ChainRulesCore, Functors, StaticArrays, Zygote
using LinearAlgebra, Statistics, Test, Random
using Optimisers: @.., @lazy
using Base.Broadcast: broadcasted, instantiate, Broadcasted
Expand Down Expand Up @@ -38,12 +38,15 @@ function Optimisers.apply!(o::BiRule, state, x, dx, dx2)
return state, dx
end

# Make Yota's output look like Zygote's:

Yota_gradient(f, xs...) = map(y2z, Base.tail(Yota.grad(f, xs...)[2]))
y2z(::AbstractZero) = nothing # we don't care about different flavours of zero
y2z(t::Tangent) = map(y2z, ChainRulesCore.backing(canonicalize(t))) # namedtuples!
y2z(x) = x
if VERSION <= v"1.10-"
# In July 2023, Yota works on 1.9 but not nightly (1.11)
using Yota
# Make Yota's output look like Zygote's:
Yota_gradient(f, xs...) = map(y2z, Base.tail(Yota.grad(f, xs...)[2]))
y2z(::AbstractZero) = nothing # we don't care about different flavours of zero
y2z(t::Tangent) = map(y2z, ChainRulesCore.backing(canonicalize(t))) # namedtuples!
y2z(x) = x
end

@testset verbose=true "Optimisers.jl" begin
@testset verbose=true "Features" begin
Expand Down

0 comments on commit 26b0134

Please sign in to comment.