Skip to content

Commit

Permalink
Update interface (#128)
Browse files Browse the repository at this point in the history
* Update interface

* Bump patch version
  • Loading branch information
willtebbutt authored Apr 30, 2024
1 parent 0f7976c commit 7d00e19
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
- 'integration_testing/array'
- 'integration_testing/turing'
- 'integration_testing/temporalgps'
- 'interface'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tapir"
uuid = "07d77754-e150-4737-8c94-cd238a1fb45b"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.2.2"
version = "0.2.3"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
10 changes: 5 additions & 5 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ ensure that you zero-out the tangent fields of `x` each time.
"""
function value_and_pullback!!(rule::R, ȳ::T, fx::Vararg{CoDual, N}) where {R, N, T}
out, pb!! = rule(fx...)
@assert _typeof(tangent(out)) == T
ty = increment!!(tangent(out), )
@assert _typeof(tangent(out)) == fdata_type(T)
increment!!(tangent(out), fdata(ȳ))
v = copy(primal(out))
return v, pb!!(ty, map(tangent, fx)...)
return v, pb!!(rdata(ȳ))
end

"""
Expand Down Expand Up @@ -48,7 +48,7 @@ use-case, consider pre-allocating the `CoDual`s and calling the other method of
function.
"""
function value_and_pullback!!(rule::R, ȳ, fx::Vararg{Any, N}) where {R, N}
return value_and_pullback!!(rule, ȳ, map(zero_codual, fx)...)
return value_and_pullback!!(rule, ȳ, map(zero_fcodual, fx)...)
end

"""
Expand All @@ -57,5 +57,5 @@ end
Equivalent to `value_and_pullback(rule, 1.0, f, x...)` -- assumes `f` returns a `Float64`.
"""
function value_and_gradient!!(rule::R, fx::Vararg{Any, N}) where {R, N}
return value_and_gradient!!(rule, map(zero_codual, fx)...)
return value_and_gradient!!(rule, map(zero_fcodual, fx)...)
end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ include("front_matter.jl")
include(joinpath("integration_testing", "turing.jl"))
elseif test_group == "integration_testing/temporalgps"
include(joinpath("integration_testing", "temporalgps.jl"))
elseif test_group == "interface"
include("interface.jl")
else
throw(error("test_group=$(test_group) is not recognised"))
end
Expand Down

2 comments on commit 7d00e19

@willtebbutt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105892

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" 7d00e19d7b097f2c5fd4f6be7d07ae549605e147
git push origin v0.2.3

Please sign in to comment.