Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ AutoZygote
AutoEnzyme
AutoChainRules
AutoDiffractor
AutoPiste
```

### Forward, reverse, or sparse mode
Expand Down
1 change: 1 addition & 0 deletions src/ADTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export AutoChainRules,
AutoModelingToolkit,
AutoMooncake,
AutoMooncakeForward,
AutoPiste,
AutoPolyesterForwardDiff,
AutoReverseDiff,
AutoSymbolics,
Expand Down
37 changes: 37 additions & 0 deletions src/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,43 @@ function Base.show(io::IO, backend::AutoMooncakeForward)
return print(io, ")")
end

"""
AutoPiste{M,chunksize}

Struct used to select the [Piste.jl](https://github.com/EvoArt/Piste.jl) backend for automatic differentiation.

Defined by [ADTypes.jl](https://github.com/SciML/ADTypes.jl).

# Constructors

AutoPiste(; mode=ForwardMode(), chunksize=nothing)

# Type parameters

- `chunksize`: the number of partials carried per forward pass (forward mode only), either `nothing` or an `Int`.
Pass an explicit value when compiling with `juliac --trim`, so that the width is known statically.

# Fields

- `mode::M`: either [`ForwardMode()`](@ref ForwardMode) (dual numbers) or [`ReverseMode()`](@ref ReverseMode) (a tape).
"""
struct AutoPiste{M <: Union{ForwardMode, ReverseMode}, chunksize} <: AbstractADType
mode::M
end

function AutoPiste(; mode::M = ForwardMode(), chunksize = nothing) where {M}
return AutoPiste{M, _unwrap_val(chunksize)}(mode)
end

mode(backend::AutoPiste) = backend.mode

function Base.show(io::IO, backend::AutoPiste{M, chunksize}) where {M, chunksize}
print(io, AutoPiste, "(")
print(io, "mode=", repr(backend.mode; context = io))
chunksize !== nothing && print(io, ", chunksize=", repr(chunksize; context = io))
return print(io, ")")
end

"""
AutoPolyesterForwardDiff{chunksize,T}

Expand Down
2 changes: 1 addition & 1 deletion src/symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Auto(package::Symbol, args...; kws...) = Auto(Val(package), args...; kws...)

for backend in (
:ChainRules, :Diffractor, :Enzyme, :Reactant, :FastDifferentiation,
:FiniteDiff, :FiniteDifferences, :ForwardDiff, :GTPSA, :HyperHessians, :Mooncake,
:FiniteDiff, :FiniteDifferences, :ForwardDiff, :GTPSA, :HyperHessians, :Mooncake, :Piste,
:PolyesterForwardDiff, :ReverseDiff, :Symbolics, :Tapir, :TaylorDiff, :Tracker, :Zygote,
)
@eval Auto(::Val{$(QuoteNode(backend))}, args...; kws...) = $(Symbol(:Auto, backend))(
Expand Down
20 changes: 20 additions & 0 deletions test/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,26 @@ end
@test ad.config === nothing
end

@testset "AutoPiste" begin
ad = AutoPiste()
@test ad isa AbstractADType
@test ad isa AutoPiste{ForwardMode, nothing}
@test mode(ad) isa ForwardMode

ad = AutoPiste(; chunksize = 4)
@test ad isa AutoPiste{ForwardMode, 4}
@test mode(ad) isa ForwardMode

ad = AutoPiste(; chunksize = Val(4))
@test ad isa AutoPiste{ForwardMode, 4}

ad = AutoPiste(; mode = ReverseMode())
@test ad isa AutoPiste{ReverseMode, nothing}
@test mode(ad) isa ReverseMode

@test_throws TypeError AutoPiste(; mode = SymbolicMode())
end

@testset "AutoPolyesterForwardDiff" begin
ad = AutoPolyesterForwardDiff()
@test ad isa AbstractADType
Expand Down
3 changes: 3 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ for backend in [
ADTypes.AutoMooncake(; config = :config),
ADTypes.AutoMooncakeForward(),
ADTypes.AutoMooncakeForward(; config = :config),
ADTypes.AutoPiste(),
ADTypes.AutoPiste(; mode = ADTypes.ReverseMode()),
ADTypes.AutoPiste(; chunksize = 4),
ADTypes.AutoPolyesterForwardDiff(),
ADTypes.AutoPolyesterForwardDiff(chunksize = 3, tag = :tag),
ADTypes.AutoReverseDiff(),
Expand Down
1 change: 1 addition & 0 deletions test/symbols.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using Test
@test ADTypes.Auto(:ForwardDiff) isa AutoForwardDiff
@test ADTypes.Auto(:HyperHessians) isa AutoHyperHessians
@test ADTypes.Auto(:Mooncake) isa AutoMooncake
@test ADTypes.Auto(:Piste) isa AutoPiste
@test ADTypes.Auto(:PolyesterForwardDiff) isa AutoPolyesterForwardDiff
@test ADTypes.Auto(:ReverseDiff) isa AutoReverseDiff
@test ADTypes.Auto(:Reactant) isa AutoReactant
Expand Down