JuliaDiff / ChainRulesTestUtils.jl

Utilities for testing custom AD primitives.
MIT License
50 stars 15 forks source link

Test functions with constraints on arguments #99

Open devmotion opened 3 years ago

devmotion commented 3 years ago

Related to https://github.com/JuliaDiff/FiniteDifferences.jl/issues/52, it seems there is currently no way to specify constraints on function arguments to FiniteDifferences. For instance, when testing the ChainRule adjoint of (an extension of) binomlogpdf(n, p, x) input p has to be constrained to the interval [0, 1] since otherwise the forward pass errors.

devmotion commented 3 years ago

In DistributionsAD we introduced a custom way to specify mappings from R^n to the desired subspace to avoid these issues in our tests (see, e.g., https://github.com/TuringLang/DistributionsAD.jl/blob/d5a479acc90acd9fe42f1abd207788c164ac85af/test/ad/distributions.jl#L252)