From 2ed2b18cb454a04528d555936395b1ec3f267832 Mon Sep 17 00:00:00 2001 From: "Tamas K. Papp" Date: Fri, 20 Dec 2019 14:01:32 +0100 Subject: [PATCH] test on Zygote unconditionally (#55) * test on Zygote unconditionally * add links to changelog, prepare for release --- CHANGELOG.md | 4 +++- Project.toml | 2 +- src/LogDensityProblems.jl | 5 +---- test/runtests.jl | 30 ++++++++++++------------------ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bd0f45..fa0ce9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased -## Major cleanup +- test Zygote on all Julia branches [#55](https://github.com/tpapp/LogDensityProblems.jl/pull/55) + +## Major cleanup [#54](https://github.com/tpapp/LogDensityProblems.jl/pull/54) - remove support for ReverseDiff - replace Flux with Tracker diff --git a/Project.toml b/Project.toml index 9ffb452..588e4d9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LogDensityProblems" uuid = "6fdf6af0-433a-55f7-b3ed-c6c6e0b8df7c" authors = ["Tamas K. Papp "] -version = "0.9.2" +version = "0.10.0" [deps] ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" diff --git a/src/LogDensityProblems.jl b/src/LogDensityProblems.jl index 688d438..53ed0e1 100644 --- a/src/LogDensityProblems.jl +++ b/src/LogDensityProblems.jl @@ -228,10 +228,7 @@ function __init__() @require DiffResults="163ba53b-c6d8-5494-b064-1a9d43ac40c5" include("DiffResults_helpers.jl") @require ForwardDiff="f6369f11-7733-5829-9624-2563aa707210" include("AD_ForwardDiff.jl") @require Tracker="9f7883ad-71c0-57eb-9f7f-b5c9e6d3789c" include("AD_Tracker.jl") - if VERSION ≥ v"1.1.0" - # workaround for https://github.com/FluxML/Zygote.jl/issues/104 - @require Zygote="e88e6eb3-aa80-5325-afca-941959d7151f" include("AD_Zygote.jl") - end + @require Zygote="e88e6eb3-aa80-5325-afca-941959d7151f" include("AD_Zygote.jl") end #### diff --git a/test/runtests.jl b/test/runtests.jl index a0d8a97..7b5ee47 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,7 +2,7 @@ using LogDensityProblems, Test, Distributions, TransformVariables import LogDensityProblems: capabilities, dimension, logdensity using LogDensityProblems: logdensity_and_gradient, LogDensityOrder -import ForwardDiff, Tracker, TransformVariables, Random +import ForwardDiff, Tracker, TransformVariables, Random, Zygote using Parameters: @unpack #### @@ -122,23 +122,17 @@ end end end -if VERSION ≥ v"1.1.0" - # cf https://github.com/FluxML/Zygote.jl/issues/104 - import Zygote - - @testset "AD via Zygote" begin - # cf https://github.com/FluxML/Zygote.jl/issues/271 - ℓ = TestLogDensity(test_logdensity1) - ∇ℓ = ADgradient(:Zygote, ℓ) - @test repr(∇ℓ) == "Zygote AD wrapper for " * repr(ℓ) - @test dimension(∇ℓ) == 3 - @test capabilities(∇ℓ) ≡ LogDensityOrder(1) - for _ in 1:100 - x = randn(3) - @test @inferred(logdensity(∇ℓ, x)) ≅ test_logdensity1(x) - @test @inferred(logdensity_and_gradient(∇ℓ, x)) ≅ - (test_logdensity1(x), test_gradient(x)) - end +@testset "AD via Zygote" begin + ℓ = TestLogDensity(test_logdensity1) + ∇ℓ = ADgradient(:Zygote, ℓ) + @test repr(∇ℓ) == "Zygote AD wrapper for " * repr(ℓ) + @test dimension(∇ℓ) == 3 + @test capabilities(∇ℓ) ≡ LogDensityOrder(1) + for _ in 1:100 + x = randn(3) + @test @inferred(logdensity(∇ℓ, x)) ≅ test_logdensity1(x) + @test @inferred(logdensity_and_gradient(∇ℓ, x)) ≅ + (test_logdensity1(x), test_gradient(x)) end end