Internal Documentation
Documentation for ComposableRecurrences's internal interface.
Contents
Index
ComposableRecurrences.TRACED_MIN_STRATAComposableRecurrences.ConvolutionMethodComposableRecurrences.ExecutorComposableRecurrences.ExponentFormComposableRecurrences.LagMapComposableRecurrences.LocalComposableRecurrences.RunBase.reverseBase.transposeComposableRecurrences._add_hazard!ComposableRecurrences._add_table!ComposableRecurrences._add_value!ComposableRecurrences._add_value_partials!ComposableRecurrences._allocComposableRecurrences._any_delaysComposableRecurrences._appliedComposableRecurrences._arrayComposableRecurrences._back_block!ComposableRecurrences._back_scratchComposableRecurrences._block!ComposableRecurrences._block_args!ComposableRecurrences._block_back!ComposableRecurrences._block_back_args!ComposableRecurrences._block_sizeComposableRecurrences._bmaxComposableRecurrences._chain_massesComposableRecurrences._check_argumentComposableRecurrences._check_coef_timesComposableRecurrences._check_coefficientComposableRecurrences._check_kernel_argsComposableRecurrences._check_lag_mapComposableRecurrences._check_lag_timesComposableRecurrences._check_lagsComposableRecurrences._check_no_delaysComposableRecurrences._check_no_stepComposableRecurrences._check_reversed_recordComposableRecurrences._check_reversed_tailComposableRecurrences._check_route_kernelComposableRecurrences._check_stepComposableRecurrences._check_transposeComposableRecurrences._check_transposed_timesComposableRecurrences._coef_arrayComposableRecurrences._coef_lagsComposableRecurrences._coef_strataComposableRecurrences._coefficient_errorComposableRecurrences._cohort_itemComposableRecurrences._colrangeComposableRecurrences._column_eltypeComposableRecurrences._column_mirrorComposableRecurrences._colviewComposableRecurrences._continuous_massesComposableRecurrences._convolve_massesComposableRecurrences._convolve_masses!ComposableRecurrences._convolve_masses_back!ComposableRecurrences._copy_time!ComposableRecurrences._correlate_masses!ComposableRecurrences._cotangent_columnComposableRecurrences._cutComposableRecurrences._delay_kernelComposableRecurrences._dense_coefComposableRecurrences._dense_kernelComposableRecurrences._dense_mirrorComposableRecurrences._dense_mirror_ofComposableRecurrences._dense_walk_back!ComposableRecurrences._dense_weights_back!ComposableRecurrences._densifiedComposableRecurrences._densified_mirrorComposableRecurrences._device_fillComposableRecurrences._device_intsComposableRecurrences._device_lag_map_errorComposableRecurrences._device_route_kernelsComposableRecurrences._device_routesComposableRecurrences._device_walk_scratchComposableRecurrences._device_weights_back!ComposableRecurrences._device_window_sumsComposableRecurrences._device_window_sums_back!ComposableRecurrences._discountedComposableRecurrences._discounted_columnComposableRecurrences._discounted_matrixComposableRecurrences._dominantComposableRecurrences._each_segmentComposableRecurrences._eigen_jacobianComposableRecurrences._eigen_stepComposableRecurrences._fill_block!ComposableRecurrences._fill_cohort!ComposableRecurrences._fill_kernelComposableRecurrences._first_arrayComposableRecurrences._first_mirrorComposableRecurrences._fixedComposableRecurrences._flipComposableRecurrences._flip_arrayComposableRecurrences._flip_inputComposableRecurrences._flip_tailComposableRecurrences._fold!ComposableRecurrences._fold_dense!ComposableRecurrences._fold_oneComposableRecurrences._fold_routesComposableRecurrences._fold_values!ComposableRecurrences._gather_outputs!ComposableRecurrences._growthComposableRecurrences._growth_coreComposableRecurrences._growth_floatComposableRecurrences._growth_gainComposableRecurrences._growth_rootComposableRecurrences._growth_solveComposableRecurrences._growth_startComposableRecurrences._growth_stepComposableRecurrences._growth_strataComposableRecurrences._growth_tolComposableRecurrences._has_delaysComposableRecurrences._has_piecesComposableRecurrences._has_strataComposableRecurrences._hazard_partialsComposableRecurrences._history_lagsComposableRecurrences._imaxComposableRecurrences._in_time_orderComposableRecurrences._increments_axpy!ComposableRecurrences._increments_dotComposableRecurrences._inner_lastComposableRecurrences._inner_spanComposableRecurrences._inverseComposableRecurrences._is_massesComposableRecurrences._isdelayComposableRecurrences._iterate_untilComposableRecurrences._joinedComposableRecurrences._keeps_fillComposableRecurrences._keeps_fill_typeComposableRecurrences._lag_axisComposableRecurrences._lag_map!ComposableRecurrences._lag_map_back!ComposableRecurrences._lag_mappedComposableRecurrences._lag_mapped_typeComposableRecurrences._lag_sumsComposableRecurrences._laggedComposableRecurrences._largest_changeComposableRecurrences._link_massesComposableRecurrences._linksComposableRecurrences._load_outputs!ComposableRecurrences._log_stepComposableRecurrences._map_lagsComposableRecurrences._massesComposableRecurrences._masses_kernelComposableRecurrences._maxlenComposableRecurrences._mirror_atComposableRecurrences._mixesComposableRecurrences._nan_likeComposableRecurrences._ncolsComposableRecurrences._nested_time_errorComposableRecurrences._newton_iterateComposableRecurrences._newton_pairComposableRecurrences._newton_stepComposableRecurrences._no_censoringComposableRecurrences._no_recordComposableRecurrences._no_walkComposableRecurrences._over_timeComposableRecurrences._over_time_errorComposableRecurrences._paddedComposableRecurrences._pairwise_piecewiseComposableRecurrences._partials_columnComposableRecurrences._pieces_typeComposableRecurrences._piecewiseComposableRecurrences._power_settledComposableRecurrences._power_stepComposableRecurrences._pressureComposableRecurrences._pressure_forwardComposableRecurrences._pressure_kernelComposableRecurrences._pressure_ruleComposableRecurrences._pressure_runComposableRecurrences._pressure_step!ComposableRecurrences._primal_matrixComposableRecurrences._rate_stepComposableRecurrences._record!ComposableRecurrences._reversed_stopComposableRecurrences._rootComposableRecurrences._route_couplingComposableRecurrences._route_forward!ComposableRecurrences._route_mirrorsComposableRecurrences._route_opComposableRecurrences._routes_back!ComposableRecurrences._routes_pressure!ComposableRecurrences._rowComposableRecurrences._row_dotComposableRecurrences._row_routeComposableRecurrences._rows_ofComposableRecurrences._safe_slopeComposableRecurrences._safe_totalComposableRecurrences._scaled_powerComposableRecurrences._scaled_sumComposableRecurrences._scratchComposableRecurrences._segmentComposableRecurrences._segment_ofComposableRecurrences._set_weight!ComposableRecurrences._settledComposableRecurrences._skipComposableRecurrences._solvableComposableRecurrences._split_indexComposableRecurrences._split_rowsComposableRecurrences._stackComposableRecurrences._stack_massesComposableRecurrences._stack_rowsComposableRecurrences._stack_valuesComposableRecurrences._start_timeComposableRecurrences._start_timesComposableRecurrences._strata_axisComposableRecurrences._strata_raggedComposableRecurrences._stratifiedComposableRecurrences._stratified_rateComposableRecurrences._stratified_typeComposableRecurrences._survival_flatComposableRecurrences._table_back!ComposableRecurrences._table_back_through!ComposableRecurrences._table_convolve!ComposableRecurrences._table_coversComposableRecurrences._table_entryComposableRecurrences._table_groupComposableRecurrences._table_groupsComposableRecurrences._table_inputsComposableRecurrences._table_kernelComposableRecurrences._table_mappedComposableRecurrences._table_mirrorComposableRecurrences._table_ofComposableRecurrences._table_scaleComposableRecurrences._table_stepComposableRecurrences._tail_mirrorsComposableRecurrences._timeComposableRecurrences._time_lengthComposableRecurrences._time_sliceComposableRecurrences._transposed_back!ComposableRecurrences._transposed_rowsComposableRecurrences._transposed_split!ComposableRecurrences._uniformComposableRecurrences._unitComposableRecurrences._valueComposableRecurrences._value_typeComposableRecurrences._values_atComposableRecurrences._values_eltypeComposableRecurrences._values_typeComposableRecurrences._walkComposableRecurrences._walk_argsComposableRecurrences._walk_backComposableRecurrences._walk_back_argsComposableRecurrences._walk_back_one!ComposableRecurrences._walk_cohort!ComposableRecurrences._walk_cohort_back!ComposableRecurrences._walk_columnComposableRecurrences._walk_cotangentComposableRecurrences._walk_fill!ComposableRecurrences._walk_groupsComposableRecurrences._walk_hazard!ComposableRecurrences._walk_indexComposableRecurrences._walk_keepsComposableRecurrences._walk_keptComposableRecurrences._walk_scratchComposableRecurrences._walk_stateComposableRecurrences._walk_strataComposableRecurrences._walk_total!ComposableRecurrences._walk_total_back!ComposableRecurrences._walk_valueComposableRecurrences._walk_valuesComposableRecurrences._walk_weights_back!ComposableRecurrences._walks_strataComposableRecurrences._walks_strata_typeComposableRecurrences._weights_arrayComposableRecurrences._weights_back!ComposableRecurrences._weights_cotangentComposableRecurrences._weights_strataComposableRecurrences._window_beforeComposableRecurrences._window_sum_at!ComposableRecurrences._window_sumsComposableRecurrences._window_sums_back!ComposableRecurrences._window_sums_back_at!ComposableRecurrences._windowsComposableRecurrences.depthComposableRecurrences.each!ComposableRecurrences.forwardComposableRecurrences.ispointwiseComposableRecurrences.param_eltypeComposableRecurrences.uses_adjoint
Internal API
ComposableRecurrences.ConvolutionMethod Type
abstract type ConvolutionMethodThe method a Convolution uses to compute its lag sum
The methods are ComposableRecurrences.Direct (the default) and ComposableRecurrences.FFTMethod.
Examples
using ComposableRecurrences
ComposableRecurrences.Direct() isa ComposableRecurrences.ConvolutionMethod
# output
trueFields
sourceComposableRecurrences.Executor Type
abstract type ExecutorA strategy for how ComposableRecurrences.each! runs a loop over independent indices. Every executor e calls the same bodies, so the result does not depend on it:
Examples
using ComposableRecurrences
ComposableRecurrences.Serial() isa ComposableRecurrences.Executor
# output
trueFields
sourceComposableRecurrences.ExponentForm Type
abstract type ExponentFormThe supertype of the depletion forms with a heterogeneity exponent Hazard and Floor.
Fields
sourceComposableRecurrences.LagMap Type
abstract type LagMapThe supertype of the maps of a computed kernel's weights over its lags: Increments and Normalised.
Fields
sourceComposableRecurrences.Local Type
struct LocalThe role of a map's local derivative at one entry: the partial derivatives of a Derived map or a ComposableRecurrences.Transform map at its arguments, given its value there.
For a map pullback!(grads, f, Local(), y, x...) returns the partial derivatives
one per argument and shaped as it is: a Transform map f(v, θ) with a tuple or NamedTuple θ returns (∂f/∂v, ∂f/∂θ), the second shaped as θ. y is the map's value there, from the forward pass. grads holds no cotangents for this role. The operators look for the method at the types of the arguments they pass, so it should accept any Real arguments. Without one the partials come from a local forward-mode derivative. The package's rules for min and max give the first argument the cotangent on a tie, so a tie can differ from ForwardDiff's convention, which also varies between its versions.
Examples
using ComposableRecurrences
CR = ComposableRecurrences
# A logistic hazard of the sum of its arguments, whose derivative reads its
# value.
struct LogisticSum end
(::LogisticSum)(a, b) = inv(1 + exp(-(a + b)))
function CR.pullback!(grads, ::LogisticSum, ::CR.Local, y, a, b)
d = y * (1 - y)
return d, d
end
h = CR.Derived(LogisticSum(), [-2.0, -1.0], 0.5)
cdf = TimeVarying(1 - CR.Survival(h), CR.Primary())
round.(CR.kernel_weights(cdf, 1); digits = 3)
# output
2×1 Matrix{Float64}:
0.182
0.491Fields
sourceComposableRecurrences.Run Type
struct RunThe role of an operator's whole call, forward(op, Run(), args...; kwargs...), which returns (y, cache); calling the operator lowers to it.
For inputs
with Recurrence or a Convolution; cache holds what the reverse pass needs, such as the ComposableRecurrences.State. It is the role an operator is asked about, as in uses_adjoint(op, Run()) and PieceInterface with role = Run().
Examples
using ComposableRecurrences
CR = ComposableRecurrences
r = Recurrence([0.5, 0.5])
y, cache = CR.forward(r, CR.Run(), fill(1.1, 4); history = ones(2))
round.(y; digits = 3)
# output
4-element Vector{Float64}:
1.1
1.155
1.24
1.317Fields
sourceComposableRecurrences.TRACED_MIN_STRATA Constant
TRACED_MIN_STRATAThe fewest strata at which a loop of a traced call runs as one kernel.
A traced call runs each step's loop over S strata as one kernel when S is at least this, so its program does not grow with the strata. A shorter loop is written out, one block a stratum. Its program grows with S, but on the CPU its forward pass runs faster than a kernel launch each step. The default, 32, is measured on the CPU. From there a kernel runs gradients faster and compiles them faster, while a written-out loop still runs the forward pass faster. A model that mostly runs forward can raise it. On a GPU, where a launch costs less, a lower value may run faster. Set it with with, as for EXECUTOR.
Examples
using ComposableRecurrences
using Base.ScopedValues: with
const CR = ComposableRecurrences
with(CR.TRACED_MIN_STRATA => 8) do
CR.TRACED_MIN_STRATA[]
end
# output
8ComposableRecurrences._add_hazard! Function
_add_hazard!(h̄, h, sc, v, k, i, τ, l) -> AnyAdd v to the cotangent of a Survival's hazard at an entry, from its kept partials where sc holds them.
ComposableRecurrences._add_table! Function
_add_table!(t̄, _::AbstractMatrix, v, k, i, τ) -> AnyAdd v to the cotangent t̄ of the entry of table t on lag index i of cohort τ, for stratum k where it has a strata axis.
ComposableRecurrences._add_value! Function
_add_value!(x̄, x::Real, sc, v, k, i, τ, l, b) -> AnyAdd v to the cotangent of a coefficient's value at an entry, through its mirror x̄; a Survival adds it to its scratch.
ComposableRecurrences._add_value_partials! Function
_add_value_partials!(
x̄,
x::ComposableRecurrences.Derived{F, A},
sc,
v,
∂,
k,
i,
τ,
l,
b
) -> AnyAdd v times each partial in ∂ of a Derived map at an entry to the cotangent of its argument, through the mirror x̄.
ComposableRecurrences._alloc Function
_alloc(_::Type{T}, dims::Int64...) -> AnyReturn a scratch buffer of element type T and size dims, its entries written before they are read.
ComposableRecurrences._any_delays Function
_any_delays(_::Type{Tuple{}}) -> BoolReturn whether any kernel type in tuple type G holds delays.
ComposableRecurrences._applied Function
_applied(lin, gain, at, v, ρ, L) -> AnyReturn M(ρ) v, from a step from the exponential history of v.
ComposableRecurrences._array Function
_array(x::AbstractArray) -> AbstractArrayReturn the array under any wrappers.
sourceComposableRecurrences._back_block! Function
_back_block!(x̄, x, sc, W̄, τ0, nb, o, last)Take the block's weight cotangents W̄ back to the mirror x̄ of coefficient x.
ComposableRecurrences._back_scratch Function
_back_scratch(sc) -> AnyReturn scratch sc for the reverse pass, with its cotangents allocated and its values and hazards shared.
ComposableRecurrences._block! Function
_block!(x, sc, τ0, nb, o, last)Fill the scratch sc of every Survival and lag map in x for the nb cohorts from τ0, inner ones first.
ComposableRecurrences._block_args! Function
_block_args!(_::Tuple{}, _::Tuple{}, τ0, nb, o, last)Fill the scratch of each argument in args, with its scratch in sc, for the block.
ComposableRecurrences._block_back! Function
_block_back!(x̄, x, sc, τ0, nb, o, last)Take the cotangents in scratch sc of the block's values back to the mirror x̄ of coefficient x, clearing them for the next block.
ComposableRecurrences._block_back_args! Function
_block_back_args!(
_::Tuple{},
_::Tuple{},
_::Tuple{},
τ0,
nb,
o,
last
)Take each argument's cotangents in its scratch in sc back to its mirror in ā, for the block.
ComposableRecurrences._block_size Function
_block_size(x, n, _::Val{keep}) -> AnyReturn the cohorts per block: all n when keep, the run's cache flag, is true or :traced and x keeps its fill, else _BLOCK.
ComposableRecurrences._bmax Function
_bmax(τ0, nb, i, o, last) -> AnyReturn how many of the nb cohorts from τ0, the first ones, have their weight on lag index i (lags from o) land by last.
ComposableRecurrences._chain_masses Function
_chain_masses(ms::Tuple{Any}, lags) -> AnyReturn the first lags masses of the convolution of the masses ms of a chain's links.
ComposableRecurrences._check_argument Function
_check_argument(
x::Union{ComposableRecurrences.LagMap, Real, ComposableRecurrences.Derived, PerStratum{<:AbstractVecOrMat{<:Number}}, ComposableRecurrences.Survival, TimeVarying{<:Any, <:Union{PerStratum{<:AbstractMatrix{<:Number}}, ComposableRecurrences._Piecewise{<:Union{PerStratum{<:AbstractMatrix{<:Number}}, AbstractVector{<:Number}}}, AbstractVector{<:Number}}}, AbstractVector{<:Number}}
)Check x as an argument of a Derived: a kernel coefficient, or else a modifier parameter.
ComposableRecurrences._check_coef_times Function
_check_coef_times(x, n, last)Check that each time-varying coefficient in x covers the cohorts up to n and the times up to last that the weights read.
ComposableRecurrences._check_coefficient Function
_check_coefficient(
x::Union{PerStratum{<:AbstractVecOrMat{<:Number}}, TimeVarying{<:Any, <:Union{PerStratum{<:AbstractMatrix{<:Number}}, ComposableRecurrences._Piecewise{<:Union{PerStratum{<:AbstractMatrix{<:Number}}, AbstractVector{<:Number}}}, AbstractVector{<:Number}}}, AbstractVector{<:Number}}
)Throw an error unless x is a coefficient a computed kernel reads, with real entries and one-based axes for an array.
ComposableRecurrences._check_kernel_args Function
_check_kernel_args(x)Check that every argument of computed kernel x is a coefficient it reads.
ComposableRecurrences._check_lag_map Function
_check_lag_map(x)Throw an error unless x is a computed kernel, or a kernel's weights with real entries, which are what a lag map takes.
ComposableRecurrences._check_lag_times Function
_check_lag_times(x, n, o)Check that the coefficients a total in x reads cover every lag of each cohort: for lags from o, the times up to n + L - 1 + o.
ComposableRecurrences._check_lags Function
_check_lags(lags, origin)Throw an error unless lags is an integer above origin, the first lag of the operator's kernel.
ComposableRecurrences._check_no_delays Function
_check_no_delays(kernel)Throw an error when kernel holds delays, since they need lags to become masses.
ComposableRecurrences._check_no_step Function
_check_no_step(width)Throw an error unless width is one, since it has meaning only where lags turns delays into masses.
ComposableRecurrences._check_reversed_record Function
_check_reversed_record(_::Val{false})Throw an ArgumentError when a reversed call's record asks for Resume().
ComposableRecurrences._check_reversed_tail Function
_check_reversed_tail(kernel, tail)Throw an ArgumentError when a Primary() kernel is given a tail.
ComposableRecurrences._check_route_kernel Function
_check_route_kernel(g)Check a route's kernel g, which may hold delays until the operator is built with lags, and reject routes given as a kernel.
ComposableRecurrences._check_step Function
_check_step(width)Throw an error unless width, the width of a lag in a delay's own unit, is a positive number.
ComposableRecurrences._check_transpose Function
_check_transpose(
kernel,
x,
tail,
start,
stop
) -> NTuple{5, Any}Check a transposed call's arguments and return the buffer eltype, the strata, the series length, the last output time and the last series time read.
sourceComposableRecurrences._check_transposed_times Function
_check_transposed_times(kernel, stop, last) -> AnyCheck that the kernel has a column for every time a transposed call reads.
sourceComposableRecurrences._coef_array Function
_coef_array(x) -> AbstractArrayReturn the first array coefficient x reads, or nothing; on a device, the weights and the walks' scratch are allocated like it.
ComposableRecurrences._coef_lags Function
_coef_lags(x) -> AnyReturn the number of lags coefficient x sets, 0 for none.
ComposableRecurrences._coef_strata Function
_coef_strata(x) -> AnyReturn the number of strata coefficient x sets, 0 for none.
ComposableRecurrences._coefficient_error Function
_coefficient_error(x)Throw the error that x is not a coefficient a computed kernel reads.
ComposableRecurrences._cohort_item Function
_cohort_item(j, nk) -> Tuple{Any, Any}Return stratum k and cohort τ of item j, with nk strata per cohort.
ComposableRecurrences._colrange Function
_colrange(g::ComposableRecurrences._Ragged, τ) -> AnyReturn the range of g.values that holds column τ.
ComposableRecurrences._column_eltype Function
_column_eltype(ks) -> AnyReturn the eltype of the columns ks, promoted over them when their type is not concrete.
ComposableRecurrences._column_mirror Function
_column_mirror(
m,
g::ComposableRecurrences._Ragged,
τ
) -> AnyReturn column τ of the mirror m of a column-form kernel's storage, or nothing without one.
ComposableRecurrences._colview Function
_colview(g::ComposableRecurrences._Ragged, τ) -> AnyReturn column τ of a column-form kernel.
ComposableRecurrences._continuous_masses Function
_continuous_masses(d, lags; kwargs...) -> AnyReturn the masses of continuous delay d, which an extension that makes the censoring choice provides; until it loads, throw an error.
ComposableRecurrences._convolve_masses Function
_convolve_masses(a, b, lags) -> AnyReturn the full linear convolution of a and b on lags 0 to lags - 1, taking only the products of entries that both exist.
ComposableRecurrences._convolve_masses! Function
_convolve_masses!(
c::AbstractVector{<:Union{Float16, Float32, Float64}},
a,
b
) -> AbstractVector{<:Union{Float16, Float32, Float64}}Add the linear convolution of a and b on the lags of c into c and return it.
ComposableRecurrences._convolve_masses_back! Function
_convolve_masses_back!(ā, b̄, c̄, a, b)Add the cotangents of a and b from the cotangent c̄ of their convolution into ā and b̄, either of which may be nothing, leaving c̄ unchanged.
ComposableRecurrences._copy_time! Function
_copy_time!(D::AbstractVector, t, V, j)Copy the value of segment j of V into time t of the dense coefficient D.
ComposableRecurrences._correlate_masses! Function
_correlate_masses!(x̄, c̄, y) -> AnyAdd the correlation of the cotangent c̄ with y into x̄, the cotangent of the convolution's other factor, and return x̄.
ComposableRecurrences._cotangent_column Function
_cotangent_column(P::AbstractVector, j) -> AbstractVectorReturn column j of the cotangent buffer P, or P when it has one column.
ComposableRecurrences._cut Function
_cut(a, lags) -> AnyReturn the masses of a on lags 0 to lags - 1, with zeros past its end.
ComposableRecurrences._delay_kernel Function
_delay_kernel(kernel, lags, origin, width) -> AnyReturn kernel with its delays turned into masses from lag origin, throwing an error for a bad lags or width or a kernel with no delays.
ComposableRecurrences._dense_coef Function
_dense_coef(x, last) -> ComposableRecurrences.SurvivalReturn coefficient x with any change points made dense over the times 1:last.
ComposableRecurrences._dense_kernel Function
_dense_kernel(
K::AbstractMatrix
) -> TimeVarying{ComposableRecurrences.Primary, A} where A<:(AbstractMatrix)Return the dense kernel of weights array K.
ComposableRecurrences._dense_mirror Function
_dense_mirror(_::Nothing)Return the mirror of a dense kernel from the cotangent K̄ of its weights array.
ComposableRecurrences._dense_mirror_of Function
_dense_mirror_of(
x̄,
x,
last
) -> Union{Nothing, NamedTuple{(:hazard,), <:Tuple{Any}}}Return the mirror of coefficient x made dense over the times 1:last, from its mirror x̄.
ComposableRecurrences._dense_walk_back! Function
_dense_walk_back!(x̄, x, K̄, o, last, sc)Take the cotangent K̄ of the weights back to the mirror x̄ of coefficients x with change points made dense.
ComposableRecurrences._dense_weights_back! Function
_dense_weights_back!(x̄, x, K̄, o, last, sc)Take the cotangent K̄ of the weights back to the mirror x̄ of coefficients x with change points made dense, with the forward scratch sc.
ComposableRecurrences._densified Function
_densified(
k::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
last
) -> TimeVarying{ComposableRecurrences.Primary}Return computed kernel k with its coefficients given by change points made dense over the times 1:last, or k when it has none.
ComposableRecurrences._densified_mirror Function
_densified_mirror(
x̄,
k::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
last
) -> AnyReturn the mirror of the dense coefficients from the mirror x̄ of the kernel's coefficients: a zero array for each made dense, and the coefficient's own mirror elsewhere.
ComposableRecurrences._device_fill Function
_device_fill(
x,
like,
_::Type{Tp},
ns,
L,
n,
o,
last
) -> Tuple{Any, Nothing}Return the weights of coefficients x, filled on the device of array like, and no scratch.
ComposableRecurrences._device_ints Function
_device_ints(like, v) -> AnyReturn the integers v copied into an array on the device of like.
ComposableRecurrences._device_lag_map_error Function
_device_lag_map_error()Throw the error that a kernel with a lag map fills only on the host.
sourceComposableRecurrences._device_route_kernels Function
_device_route_kernels(_::Tuple{}) -> BoolReturn whether every route kernel in gs is a fixed kernel.
ComposableRecurrences._device_routes Function
_device_routes(_::Tuple{}) -> BoolReturn whether every route coupling in Cs is a matrix on the device.
ComposableRecurrences._device_walk_scratch Function
_device_walk_scratch(x, _::Type, L, m, like) -> AnyReturn the walk scratch for m blocks of walks of L lags on the device of array like, or nothing where x holds no Survival.
ComposableRecurrences._device_weights_back! Function
_device_weights_back!(x̄, x, K̄, o, last)Take the cotangent K̄ of the weights back to the mirror x̄ on the device, walking each cohort again in blocks.
ComposableRecurrences._device_window_sums Function
_device_window_sums(
op::ComposableRecurrences._WindowSums,
lo,
hi,
x
) -> AnyReturn the window sums of x on its device, one kernel index per sum.
ComposableRecurrences._device_window_sums_back! Function
_device_window_sums_back!(
x̄,
op::ComposableRecurrences._WindowSums,
lo,
hi,
ȳ
) -> AnyAdd each window's cotangent to x̄ on its device, one kernel index per time.
ComposableRecurrences._discounted Function
_discounted(
lin,
gain,
at,
v::Number,
ρ,
L
) -> Tuple{Any, Any}Return M(ρ) v and -M'(ρ) v from two steps at time at: one from the history v exp(ρ (l - L)) and one from that history times its lags.
ComposableRecurrences._discounted_column Function
_discounted_column(lin, gain, at, ρ, L, S, j) -> AnyReturn column j of M(ρ), from a step from stratum j's unit profile.
ComposableRecurrences._discounted_matrix Function
_discounted_matrix(
lin,
gain,
at,
ρ,
L::Integer,
S::Integer
) -> AnyReturn the matrix M(ρ), a column per stratum's unit profile.
ComposableRecurrences._dominant Function
_dominant(M) -> Tuple{Any, Any, Any}
_dominant(M, tol) -> Tuple{Any, Any, Any}Return the largest eigenvalue of a non-negative matrix whose strata all reach each other, with its right and left vectors, each summing to one.
sourceComposableRecurrences._each_segment Function
_each_segment(f, p::ComposableRecurrences._Piecewise, n)Call f(t, j) for each time t in 1:n and its segment j of change points p.
ComposableRecurrences._eigen_jacobian Function
_eigen_jacobian(
lin,
gain,
at,
ρ,
L,
S
) -> Tuple{Any, Any, Any}
_eigen_jacobian(
lin,
gain,
at,
ρ,
L,
S,
v
) -> Tuple{Any, Any, Any}Return ρ, the profile at ρ unless given, and the inverse Jacobian of F there.
ComposableRecurrences._eigen_step Function
_eigen_step(x, lin, gain, at, L, S) -> Tuple{Any, Any}Return the next Newton iterate of the rate on log λ(ρ) from x, for strata that mix.
ComposableRecurrences._fill_block! Function
_fill_block!(W, x, sc, τ0, nb, o, last) -> AnyFill the block's weights into W (cohorts × lags × strata) and return W.
ComposableRecurrences._fill_cohort! Function
_fill_cohort!(j, K, x, o, last, nk)Fill the weights in K of item j, one stratum of one cohort, by walking its lags.
ComposableRecurrences._fill_kernel Function
_fill_kernel(
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
o,
n,
last
) -> Tuple{Any, Any}
_fill_kernel(
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
o,
n,
last,
keep::Val
) -> Tuple{Any, Any}Return the weights of kernel for n cohorts, lags from o and times up to last, with the scratch its reverse pass reads.
ComposableRecurrences._first_array Function
_first_array(_::Tuple{})Return the first entry of tuple a that is not nothing, or nothing when there is none.
ComposableRecurrences._first_mirror Function
_first_mirror(_::Nothing)Return the first of the argument mirrors ā, or nothing when there are none.
ComposableRecurrences._fixed Function
_fixed(x::Number) -> AnyReturn the value of x with no derivative.
ComposableRecurrences._flip Function
_flip(
x::Union{Nothing, AbstractString, Function, Number, Symbol, Val, AbstractArray, Type, LinearAlgebra.UniformScaling},
w
) -> Union{Nothing, AbstractString, Function, Number, Symbol, Val, AbstractArray, Type, LinearAlgebra.UniformScaling}Return x with every TimeVarying array it holds read at its columns w, last first.
ComposableRecurrences._flip_array Function
_flip_array(A::AbstractArray, w) -> AnyReturn the columns w of an array over time, last first, all of them when w is left out.
ComposableRecurrences._flip_input Function
_flip_input(x::AbstractVecOrMat, w) -> AnyReturn a call's gain or add on the reversed axis: an array is over time, and anything else is a parameter, read as the operator's are.
ComposableRecurrences._flip_tail Function
_flip_tail(
tail::Union{Nothing, Number}
) -> Union{Nothing, Number}Return the outputs after stop, nearest last, as the history of the run.
ComposableRecurrences._fold! Function
_fold!(x̄, x, x̄d) -> AnySum the dense cotangents x̄d of coefficient x onto the mirrors x̄ of its values given by change points.
ComposableRecurrences._fold_dense! Function
_fold_dense!(
x̄,
k::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
x̄d
)Sum each dense cotangent in x̄d onto the value of its time's segment in the mirror x̄.
ComposableRecurrences._fold_one Function
_fold_one(C, g, R, J) -> Tuple{Any, Any}Return a lone route's kernel g and coupling C, or (R, J) when g is itself pairwise.
ComposableRecurrences._fold_routes Function
_fold_routes(
Cs,
gs,
R,
J
) -> Tuple{AbstractVector, LinearAlgebra.UniformScaling}Return the kernel and coupling that routes with couplings Cs and kernels gs fold to, or (R, J) when they do not fold.
ComposableRecurrences._fold_values! Function
_fold_values!(V̄, D̄::AbstractVector, p)Add each time's dense cotangent in D̄ to the cotangent V̄ of its segment's value in change points p.
ComposableRecurrences._gather_outputs! Function
_gather_outputs!(_::Nothing, H̄, D)Add the cotangents of the buffer rows after the history to the outputs' cotangent ȳ.
ComposableRecurrences._growth Function
_growth(
_::Type,
lin,
gain,
at
) -> NamedTuple{(:rate, :profile), <:Tuple{Any, Any}}Return the rate and profile of growth for the linear recurrence lin.
ComposableRecurrences._growth_core Function
_growth_core(
r::Recurrence{<:Any, <:Any, Tuple{}}
) -> Recurrence{<:Any, <:Any, Tuple{}}Return the recurrence with the kernel and coupling of r and no modifiers.
ComposableRecurrences._growth_float Function
_growth_float(lin, xs...) -> AnyReturn the float type of the parameters of the kernel, coupling and xs.
ComposableRecurrences._growth_gain Function
_growth_gain(
_::Val{false},
_::Val{false},
lin,
rate,
at
) -> AnyReturn the scale of the gain at which lin grows at rate, as growth_gain does.
ComposableRecurrences._growth_root Function
_growth_root(
_::Val{false},
stratified,
lin,
gain,
at
) -> AnyReturn the root rate with no derivative, and for strata that mix also its profile and the inverse Jacobian there.
sourceComposableRecurrences._growth_solve Function
_growth_solve(
lin,
gain,
at
) -> NamedTuple{(:rate, :profile), <:Tuple{Any, Any}}Return the rate and profile: the root found with no derivative, then one Newton step from it.
sourceComposableRecurrences._growth_start Function
_growth_start(lin, gain, at, v, L) -> AnyReturn where Newton starts: the first step from zero, which for one series with a kernel vector is log(γ Σ g) / l̄ and needs no exponential.
ComposableRecurrences._growth_step Function
_growth_step(
_::Val{false},
_::Val{false},
lin,
gain,
at,
ρ
) -> NamedTuple{(:rate, :profile), <:Tuple{Any, Bool}}Return (; rate, profile) after one Newton step from the root ρ, which carries the derivative.
ComposableRecurrences._growth_strata Function
_growth_strata(r::Recurrence, xs...) -> AnyReturn the number of strata, from the first of xs, the kernel and the coupling that has a row per stratum.
ComposableRecurrences._growth_tol Function
_growth_tol(ρ) -> AnyReturn the tolerance of the root, the square root of the precision of the float type of ρ.
ComposableRecurrences._has_delays Function
_has_delays(_::Type{T}) -> BoolReturn whether a kernel of type T holds delays.
ComposableRecurrences._has_pieces Function
_has_pieces(x) -> AnyReturn whether coefficient x holds a coefficient given by change points, fixed at compile time from its type.
ComposableRecurrences._has_strata Function
_has_strata(x) -> Val{true}Return whether x has a row per stratum, as a Val read from its type.
ComposableRecurrences._hazard_partials Function
_hazard_partials(h, _::Type, dims, keep) -> AnyReturn an array of size dims that keeps the partials of a costly hazard map h when every walk is kept, else nothing.
ComposableRecurrences._history_lags Function
_history_lags(L) -> AnyReturn the lag each column of an L-step history holds at the step after it.
ComposableRecurrences._imax Function
_imax(τ, L, o, last) -> AnyReturn the last lag index of cohort τ whose weight lands by last, for lags from o.
ComposableRecurrences._in_time_order Function
_in_time_order(y::AbstractArray) -> AnyReturn the outputs of a reversed run, or a tuple or named tuple of them, in time order.
sourceComposableRecurrences._increments_axpy! Function
_increments_axpy!(Y, k, r, t, k0, τ, i0, imax, a) -> AnyAdd u_i a to Y[r + i, k] over lag indices i0:imax, with u the increments of table t for cohort τ, and return Y.
ComposableRecurrences._increments_dot Function
_increments_dot(t, k0, τ, i0, imax, Ȳ, k, r) -> AnyReturn Σ_i u_i Ȳ[r + i, k] over lag indices i0:imax, with u the increments of table t for cohort τ.
ComposableRecurrences._inner_last Function
_inner_last(
_::ComposableRecurrences.Increments,
τ0,
nb,
L,
o,
last
) -> AnyReturn the last time lag map x reads the kernel inside at for the nb cohorts from τ0.
ComposableRecurrences._inner_span Function
_inner_span(
_::ComposableRecurrences.Increments,
last
) -> AnyReturn the last time lag map x reads the kernel inside at: a total reads every lag of the last cohort, one step on for a recurrence's offset.
ComposableRecurrences._inverse Function
_inverse(J) -> AnyReturn the inverse of J, or NaN entries when J is not finite, where a factorisation would throw.
ComposableRecurrences._is_masses Function
_is_masses(_::Type{H}) -> BoolReturn whether a link of type H is a vector of masses: a vector of real numbers, or of a number type that stands for one and adds a method.
ComposableRecurrences._isdelay Function
_isdelay(_::Type{T}) -> BoolReturn whether type T is a delay: not an array, and with a delay_masses method.
ComposableRecurrences._iterate_until Function
_iterate_until(
step,
done,
x::Tuple,
n::Integer,
args...
) -> Tuple{Any, Bool}Apply x ← step(x, args...) until done(x, args...), at most n times, and return x and whether it was done.
ComposableRecurrences._joined Function
_joined(f, _::Tuple{}, what) -> Int64Return the count that f gives the arguments args of a Derived, throwing an error when two nonzero counts of what differ.
ComposableRecurrences._keeps_fill Function
_keeps_fill(x) -> AnyReturn whether the fill of coefficient x is kept for the reverse pass, a costly map without a lag map, fixed at compile time from its type.
ComposableRecurrences._keeps_fill_type Function
_keeps_fill_type(_::Type) -> Union{Missing, Bool}Return whether a coefficient of type T has a map other than +, -, * and /, from the type.
ComposableRecurrences._lag_axis Function
_lag_axis(W::AbstractArray{<:Any, 3}) -> AnyReturn the lag axis of a block of weights W.
ComposableRecurrences._lag_map! Function
_lag_map!(
w,
_::ComposableRecurrences.Increments,
u,
n
) -> AnyWrite the weights of lags 1:n from the values u of the kernel inside the lag map into w and return w.
ComposableRecurrences._lag_map_back! Function
_lag_map_back!(
ū,
_::ComposableRecurrences.Increments,
w̄,
u,
n
) -> AnyWrite the cotangents ū of the values inside from the cotangents w̄ of the weights, where ū may be w̄, and return ū.
ComposableRecurrences._lag_mapped Function
_lag_mapped(x) -> AnyReturn whether coefficient x holds a lag map, fixed at compile time from its type.
ComposableRecurrences._lag_mapped_type Function
_lag_mapped_type(_::Type) -> BoolReturn whether a coefficient of type T holds a lag map, from the type.
ComposableRecurrences._lag_sums Function
_lag_sums(k::AbstractVector, ρ, j) -> Tuple{Any, Any}Return the sum of stratum j's kernel discounted at ρ, and the same weighted by its lags.
ComposableRecurrences._lagged Function
_lagged(lin, gain, at, v, ρ, L) -> AnyReturn -M'(ρ) v, from a step from the exponential history of v times its lags.
ComposableRecurrences._largest_change Function
_largest_change(w, v) -> AnyReturn the largest change between the values of v and w, with no derivative.
ComposableRecurrences._link_masses Function
_link_masses(
k::AbstractVector,
lags,
width
) -> AbstractVectorReturn the masses of chain link d: a vector as it is, whatever its length, or a delay's masses, checked to have lags entries.
ComposableRecurrences._links Function
_links(_::Type{Tuple{}}) -> BoolReturn whether each link of tuple type T is a vector of masses or a delay.
ComposableRecurrences._load_outputs! Function
_load_outputs!(
H,
y::AbstractVector,
D
) -> GPUArraysCore.AnyGPUArrayWrite the outputs y into the buffer rows after the history.
ComposableRecurrences._log_step Function
_log_step(m, d) -> AnyReturn the Newton step log(m) m / d without checking that m has a logarithm.
ComposableRecurrences._map_lags Function
_map_lags(
_::ComposableRecurrences.Increments,
τ,
L,
o,
last
) -> AnyReturn how many lags of cohort τ lag map x reads: those whose weights land by last, or every lag for a total.
ComposableRecurrences._masses Function
_masses(d, grid, origin) -> AnyReturn the masses of d from lag origin, on the grid.lags lags of grid.width units each.
ComposableRecurrences._masses_kernel Function
_masses_kernel(
x,
grid,
origin
) -> ComposableRecurrences._RoutesReturn kernel x with any delays it holds turned into masses from lag origin on grid.
ComposableRecurrences._maxlen Function
_maxlen(g::ComposableRecurrences._Ragged) -> AnyReturn the length of the longest column of a column-form kernel.
sourceComposableRecurrences._mirror_at Function
_mirror_at(_::Nothing, τ)Return entry τ of the mirror m, or nothing without one.
ComposableRecurrences._mixes Function
_mixes(r::Recurrence) -> Union{Val{true}, Val{false}}Return whether strata mix, as a Val read from the types.
ComposableRecurrences._nan_like Function
_nan_like(x::Number) -> AnyReturn a NaN of the float type of the value of x, or an array of them.
ComposableRecurrences._ncols Function
_ncols(g::ComposableRecurrences._Ragged) -> AnyReturn the number of columns of a column-form kernel.
sourceComposableRecurrences._nested_time_error Function
_nested_time_error(x)Throw the ArgumentError for a TimeVarying that wraps another.
ComposableRecurrences._newton_iterate Function
_newton_iterate(ρ::Number, m, d) -> Tuple{Any, Any}Return the Newton iterate (ρ + Δ, Δ) from ρ, for one series or per stratum.
ComposableRecurrences._newton_pair Function
_newton_pair(Jinv, r) -> AnyReturn the Newton step J⁻¹ F on F = (r, 0).
ComposableRecurrences._newton_step Function
_newton_step(m::Real, d::Real) -> AnyReturn the Newton step on log m(ρ) from m and d = -m'(ρ): NaN where m has no logarithm, which ends the solve as a settled step does.
ComposableRecurrences._no_censoring Function
_no_censoring(d)Throw the error that continuous delay d has no masses on whole lags until a censoring choice discretises it.
ComposableRecurrences._no_record Function
_no_record(sc) -> AnyReturn scratch sc with each Survival's part replaced by one that records nothing.
ComposableRecurrences._no_walk Function
_no_walk(x) -> AnyReturn the scratch of a walk that records nothing, built inside a kernel.
sourceComposableRecurrences._over_time Function
_over_time(x) -> BoolReturn whether TimeVarying can wrap x.
ComposableRecurrences._over_time_error Function
_over_time_error(x)Throw the ArgumentError for a value TimeVarying cannot wrap.
ComposableRecurrences._padded Function
_padded(x, tail, N) -> AnyReturn the series and tail joined, with zeros after them up to time N.
ComposableRecurrences._pairwise_piecewise Function
_pairwise_piecewise(x)Throw the ArgumentError for Pairwise values given as change points.
ComposableRecurrences._partials_column Function
_partials_column(_::Nothing, j)Return column j of the kept partials D, or nothing when none are kept.
ComposableRecurrences._pieces_type Function
_pieces_type(_::Type) -> BoolReturn whether a coefficient of type T holds a coefficient given by change points, from the type.
ComposableRecurrences._piecewise Function
_piecewise(
ps::AbstractVector{<:Pair}
) -> ComposableRecurrences._Piecewise{_A, Vector{Int64}} where _AReturn a _Piecewise of the values of start => value change points stacked along a new last axis, kernels of different lengths padded with zero weights.
ComposableRecurrences._power_settled Function
_power_settled(x, tol) -> AnyReturn whether the row sums of the power iterate x moved by at most tol.
ComposableRecurrences._power_step Function
_power_step(x, tol) -> Tuple{Any, Any, Any}Return the next power iterate, the square of the power in x rescaled.
ComposableRecurrences._pressure Function
_pressure(r::Recurrence, route, y; history, start) -> AnyCheck the arguments of pressure and compute it with _Pressure, taking the rule as route does.
ComposableRecurrences._pressure_forward Function
_pressure_forward(
r,
y,
h,
τ0,
keep::Val
) -> Tuple{Any, Union{Nothing, NamedTuple{(:H, :P, :kernel, :h, :τ0, :L, :D, :S, :T), <:Tuple{Any, Any, Any, AbstractVector, Vararg{Any, 5}}}, NamedTuple{(:H, :P, :kernel, :h, :τ0, :L, :D, :S, :T), <:Tuple{Any, Any, Any, AbstractMatrix, Vararg{Any, 5}}}}}Return the pressure of the outputs y after the history h from time τ0, with what the reverse pass needs when keep is Val(true).
ComposableRecurrences._pressure_kernel Function
_pressure_kernel(
r::Recurrence,
stop
) -> Union{Recurrence{K} where K<:(TimeVarying{ComposableRecurrences.Primary, A} where A<:(AbstractMatrix)), Recurrence{K} where K<:(TimeVarying{ComposableRecurrences.Primary, A} where A<:(PerStratum{A} where A<:(AbstractArray{<:Any, 3})))}Return the recurrence whose kernel the pressure reads up to time stop.
ComposableRecurrences._pressure_rule Function
_pressure_rule(kernel) -> BoolReturn whether pressure takes its rule for kernel.
ComposableRecurrences._pressure_run Function
_pressure_run(
_::Type{Tp},
r,
y,
h,
τ0,
L,
D,
S,
T,
keep::Val
) -> Union{Tuple{Any, Nothing}, Tuple{Any, NamedTuple{(:H, :P, :kernel, :h, :τ0, :L, :D, :S, :T), <:NTuple{9, Any}}}}Return the pressure at every step, with the buffer and each step's kernel convolutions P for the reverse pass when keep is Val(true).
ComposableRecurrences._pressure_step! Function
_pressure_step!(
t,
out,
P,
coupling,
g,
p,
q,
H,
τ0,
L,
D,
S
)Write step t's pressure on every stratum, read as the run's step reads it, and its kernel convolutions into P when the reverse pass keeps them.
ComposableRecurrences._primal_matrix Function
_primal_matrix(lin, gain, at, ρ, L, S) -> AnyReturn M(ρ) with no derivative.
ComposableRecurrences._rate_step Function
_rate_step(x, lin, gain, at, v, L) -> Tuple{Any, Any}Return the next Newton iterate of the rate from x, for strata that do not mix.
ComposableRecurrences._record! Function
_record!(_::ComposableRecurrences._NoRecord, i, s, η)Record survival s and hazard η at lag index i in walk scratch sc, unless it records nothing.
ComposableRecurrences._reversed_stop Function
_reversed_stop(stop::Integer, gain, add) -> AnyReturn the last time of a reversed call: stop when given, else the length over time of gain or add.
ComposableRecurrences._root Function
_root(ρ::Number, found) -> AnyReturn the root with no derivative, or NaN when the solve did not settle.
sourceComposableRecurrences._route_coupling Function
_route_coupling(C) -> GPUArrays.AbstractGPUSparseMatrixCSRReturn route coupling C in the form it is stored, which is C itself unless a method for its type says otherwise.
ComposableRecurrences._route_forward! Function
_route_forward!(C, w, z, τ) -> AnyWrite into w the pressure that route coupling C gives from the route's kernel pressure z.
ComposableRecurrences._route_mirrors Function
_route_mirrors(_::Nothing, xs) -> AnyReturn each route's mirror from x̄s, or nothing for each route in xs when no cotangent is carried.
ComposableRecurrences._route_op Function
_route_op(r::Recurrence) -> RecurrenceReturn the recurrence a NoAdjoint wraps, or the recurrence itself.
ComposableRecurrences._routes_back! Function
_routes_back!(
_::Tuple{},
pbufs,
ḡs,
C̄s,
Cs,
gs,
Ls,
z,
z̄,
p̄,
H,
H̄,
t,
τ,
L
)For each route, recompute its convolution z, send p̄ back through its coupling into z̄, then through its kernel into its buffer in kbuf.
ComposableRecurrences._routes_pressure! Function
_routes_pressure!(
ex,
p,
z,
w,
_::Tuple{},
_::Tuple{},
_::Tuple{},
H,
t,
τ,
L
)Add each route's coupled pressure at step t to p, with z and w as work vectors.
ComposableRecurrences._row Function
_row(
sc::ComposableRecurrences._SurvivalScratch{false},
k
) -> Int64Return the row of scratch sc that stratum k reads: 1 without a strata axis, else k.
ComposableRecurrences._row_dot Function
_row_dot(K, i, x) -> AnyReturn the dot product of row i of K with x.
ComposableRecurrences._row_route Function
_row_route(route, op) -> ComposableRecurrences.NoAdjointReturn op, wrapped in NoAdjoint when route is one.
ComposableRecurrences._rows_of Function
_rows_of(x) -> AnyReturn the number of strata x has rows for, or nothing when it has no row per stratum.
ComposableRecurrences._safe_slope Function
_safe_slope(t) -> AnyReturn the slope of the floored total at t: one above eps, and zero at or below it.
ComposableRecurrences._safe_total Function
_safe_total(t) -> AnyReturn total t, or eps when t is at most eps, as a max with no branch on its value.
ComposableRecurrences._scaled_power Function
_scaled_power(B) -> Tuple{Any, Any, Any}Return B over the sum of its entries, its row sums and their largest change from v, the row sums of a uniform matrix when left out.
ComposableRecurrences._scaled_sum Function
_scaled_sum(Cs, gs) -> AnyReturn Σ_r λ_r g_r for scaled identity couplings Cs and vector kernels gs, each kernel zero past its end.
ComposableRecurrences._scratch Function
_scratch(x, ::Type, L) -> Any
_scratch(x, ::Type, L, B) -> AnyReturn the scratch that the Survivals and lag maps in x fill for a block of B cohorts and L lags, or nothing when there are none.
ComposableRecurrences._segment Function
_segment(p::ComposableRecurrences._Piecewise, t) -> AnyReturn the segment of time t: the last whose start is at or before t, the first for a time before 1.
ComposableRecurrences._segment_of Function
_segment_of(s, t) -> AnyReturn the index of the last start in s at or before t, or 1 when none is.
ComposableRecurrences._set_weight! Function
_set_weight!(K::AbstractMatrix, v, k, i, τ)Set the weight on lag index i of cohort τ in weights array K, for stratum k where it has a strata axis, to v.
ComposableRecurrences._settled Function
_settled(Δ::Number, ρ::Number) -> AnyReturn whether the Newton step Δ from ρ is within the tolerance, in every entry for arrays.
ComposableRecurrences._skip Function
_skip(i, l, st)Do nothing, as the callback of a walk that only records.
sourceComposableRecurrences._solvable Function
_solvable(x::Number) -> AnyReturn whether x, or every entry of it, is positive and finite, the values for which a rate exists.
ComposableRecurrences._split_index Function
_split_index(i, m) -> Tuple{Any, Any}Return the row and column of linear index i in a matrix of m rows.
ComposableRecurrences._split_rows Function
_split_rows(
_::ComposableRecurrences._SplitRows{S},
Y
) -> TupleReturn the rows of Y as a tuple of S vectors.
ComposableRecurrences._stack Function
_stack(_::Type{V}, get, ps, sz) -> AnyReturn the values get(p), each of size sz, copied into the slices of one zeroed array on their device.
ComposableRecurrences._stack_masses Function
_stack_masses(A, grid, origin) -> AnyReturn the masses from lag origin of each delay in array A as one array, lags first and the axes of A after.
ComposableRecurrences._stack_rows Function
_stack_rows(xs::Tuple) -> AnyReturn the series of the tuple xs, checked to share one length, stacked as the rows of a strata × time matrix.
ComposableRecurrences._stack_values Function
_stack_values(_::Type{<:Real}, get, ps) -> AnyReturn the values get(p) of the pairs ps stacked along a new last axis, in the form the type V picks.
ComposableRecurrences._start_time Function
_start_time(p::Pair{<:Integer}) -> IntegerReturn the start time of the change point p, an ArgumentError when it is not an integer.
ComposableRecurrences._start_times Function
_start_times(ps) -> AnyReturn the start times of the change points ps.
ComposableRecurrences._strata_axis Function
_strata_axis(W::AbstractArray{<:Any, 3}) -> AnyReturn the strata axis of a block of weights W.
ComposableRecurrences._strata_ragged Function
_strata_ragged(x)Throw the ArgumentError for a per-stratum or pairwise kernel given as kernel columns.
ComposableRecurrences._stratified Function
_stratified(x) -> AnyReturn whether coefficient x has a strata axis, fixed at compile time from its type.
_stratified(r::Recurrence, gain) -> AnyReturn whether the gain or kernel has a row per stratum, as a Val read from the types.
ComposableRecurrences._stratified_rate Function
_stratified_rate(rate) -> Val{true}Return whether rate has one value per stratum, as a Val.
ComposableRecurrences._stratified_type Function
_stratified_type(_::Type) -> Union{Missing, Bool}Return whether a coefficient of type T has a strata axis, whose count _coef_strata then gives, from the type alone so the kernel's shape infers.
ComposableRecurrences._survival_flat Function
_survival_flat(
hazard,
from
) -> ComposableRecurrences.SurvivalReturn the Survival rebuilt from its fields, as constructorof gives it.
ComposableRecurrences._table_back! Function
_table_back!(X̄, Y, t̄, x, X, Ȳ, m, start)Run the reverse pass of a table's convolution, adding into input mirror X̄, table mirror t̄ and transposed product Y, each skipped when nothing.
ComposableRecurrences._table_back_through! Function
_table_back_through!(X̄, Y, c̄, c, X, Ȳ, m, start)Take the kernel's mirror c̄ to the table's mirror, then run the reverse pass of the table's convolution.
ComposableRecurrences._table_convolve! Function
_table_convolve!(Y, x, X, m, start) -> AnyAdd the convolution of input rows X, from row m, with lag map x of a weights table into Y, whose rows are the times from start, and return Y.
ComposableRecurrences._table_covers Function
_table_covers(K, stop) -> AnyThe table K with zero columns after its last input time up to stop, so its kernel covers the call's times.
Arguments
K: anL × norS × L × ntable.stop: the last time of the call, ornothingforn.
ComposableRecurrences._table_entry Function
_table_entry(t::AbstractMatrix, k, i, τ) -> AnyReturn the weight on lag index i of cohort τ in table t, for stratum k where the table has a strata axis.
ComposableRecurrences._table_group Function
_table_group(t::AbstractMatrix, ks, k0) -> AnyReturn the strata of ks that group k0 serves: all of them for a table of one stratum's weights, else k0 alone.
ComposableRecurrences._table_groups Function
_table_groups(t::AbstractMatrix, ks) -> Base.OneTo{Int64}Return the groups to loop over: one for a table of one stratum's weights, which serves every stratum, or each stratum of ks for a table with a stratum axis.
ComposableRecurrences._table_inputs Function
_table_inputs(K::AbstractMatrix) -> AnyInputs of one for each input time of the table K, one series per stratum.
Arguments
K: anL × norS × L × ntable.
ComposableRecurrences._table_kernel Function
_table_kernel(K::AbstractMatrix) -> AbstractMatrixThe kernel weights of the table K: K itself, or PerStratum(K) for one table per stratum.
Arguments
K: anL × norS × L × ntable.
ComposableRecurrences._table_mapped Function
_table_mapped(x) -> BoolReturn whether x is the increments of a table of a kernel's weights, or those normalised, which read the table in place.
ComposableRecurrences._table_mirror Function
_table_mirror(
x̄,
x::ComposableRecurrences.Increments{<:Union{TimeVarying{ComposableRecurrences.Primary, <:AbstractMatrix{<:Number}}, TimeVarying{ComposableRecurrences.Primary, <:AbstractArray{<:Number, 3}}}}
) -> AnyReturn the table's mirror inside the mirror x̄ of the kernel's lag maps.
ComposableRecurrences._table_of Function
_table_of(
x::ComposableRecurrences.Increments{<:Union{TimeVarying{ComposableRecurrences.Primary, <:AbstractMatrix{<:Number}}, TimeVarying{ComposableRecurrences.Primary, <:AbstractArray{<:Number, 3}}}}
) -> Union{AbstractArray{<:Number, 3}, AbstractMatrix{<:Number}}Return the table of weights inside lag map x.
ComposableRecurrences._table_scale Function
_table_scale(
x::ComposableRecurrences.Increments{<:Union{TimeVarying{ComposableRecurrences.Primary, <:AbstractMatrix{<:Number}}, TimeVarying{ComposableRecurrences.Primary, <:AbstractArray{<:Number, 3}}}},
t,
k,
τ,
L
) -> Tuple{Any, Any}Return the scale of cohort τ's increments and the slope of its total's floor.
ComposableRecurrences._table_step Function
_table_step(t, k, i, τ) -> AnyReturn the increment of table t on lag index i > 1.
ComposableRecurrences._tail_mirrors Function
_tail_mirrors(_::Nothing)Return the argument mirrors ā after the first, or nothing when there are none.
ComposableRecurrences._time Function
_time(
_::TimeVarying{ComposableRecurrences.Primary},
τ,
l
) -> AnyReturn the time a coefficient is read at for lag l of cohort τ: the cohort's own time, or the time the weight lands.
ComposableRecurrences._time_length Function
_time_length(x) -> AnyReturn the length over time of an array, or nothing for anything else.
ComposableRecurrences._time_slice Function
_time_slice(A::AbstractVector, w) -> AnyReturn the columns w of A along its last axis.
ComposableRecurrences._transposed_back! Function
_transposed_back!(ex, Ā, k̄, kernel, Z̄, A, o, start)Compute the series' cotangent Ā from the convolution's forward body, then the kernel's k̄ from its reverse body.
ComposableRecurrences._transposed_rows Function
_transposed_rows(kernel, last, stop) -> AnyReturn the rows the bodies fill and read for the outputs, past stop for most kernels.
ComposableRecurrences._transposed_split! Function
_transposed_split!(ex, Ā, k̄, kernel, Z̄, A, o, start)Compute the series' cotangent and then the kernel's in two separate passes.
sourceComposableRecurrences._uniform Function
_uniform(tol, S) -> AnyReturn a vector of S entries 1 / S in the type of tol.
ComposableRecurrences._unit Function
_unit(_::Val{false}, lin, gain) -> AnyReturn the profile of strata that do not mix: one for a series, one per stratum.
sourceComposableRecurrences._value Function
_value(x::Real, sc, k, i, τ, l, b) -> RealReturn the value of coefficient x on lag index i (lag l) of cohort τ in stratum k, reading entry b of the block's scratch sc where it needs.
ComposableRecurrences._value_type Function
_value_type(_::Type{<:Pair{<:Any, V}}) -> AnyReturn the value type of a Pair type.
ComposableRecurrences._values_at Function
_values_at(_::Tuple{}, _::Tuple{}, k, i, τ, l, b) -> Tuple{}Return the values of arguments a at an entry, each with its scratch in sc.
ComposableRecurrences._values_eltype Function
_values_eltype(_::Type{V}, get, ps) -> AnyReturn the eltype of the stacked values: that of V when concrete, else promoted over the values.
ComposableRecurrences._values_type Function
_values_type(_::Type{V}, get, ps) -> AnyReturn the type that picks how the values get(p) stack: V when concrete, else the join of the values' own types, as for pairs typed Pair{Int, Any}.
ComposableRecurrences._walk Function
_walk(x, sc, st, k, i, τ, l) -> TupleReturn the state at lag index i (lag l) of cohort τ, stratum k, from the state st at the lag before, inner Survivals first.
ComposableRecurrences._walk_args Function
_walk_args(
_::Tuple{},
_::Tuple{},
_::Tuple{},
k,
i,
τ,
l
) -> Tuple{}Return the states of arguments a at an entry, each from its state in st.
ComposableRecurrences._walk_back Function
_walk_back(x̄, x, sc, a, k, i, τ, l) -> AnyReturn the carried cotangents at the lag index before i, from those a at i, adding to the mirror x̄ on the way.
ComposableRecurrences._walk_back_args Function
_walk_back_args(
ā,
_::Tuple{},
_::Tuple{},
_::Tuple{},
k,
i,
τ,
l
) -> Tuple{}Return the carried cotangents of arguments x one lag index back, each from its own in a.
ComposableRecurrences._walk_back_one! Function
_walk_back_one!(x̄, x, sc, K̄, k, τ, o, last)Walk cohort τ of stratum k again, add its weights' cotangents, and walk it back.
ComposableRecurrences._walk_cohort! Function
_walk_cohort!(f, x, sc, k, τ, o, imax, _::Type{T})Walk cohort τ from lag index 1 to imax, lags from o, for stratum k, calling f(i, l, st) with the state at each lag.
ComposableRecurrences._walk_cohort_back! Function
_walk_cohort_back!(x̄, x, sc, k, τ, o, imax, _::Type{T})Walk back along cohort τ's lags from imax, once the cotangents of its weights are added.
ComposableRecurrences._walk_column Function
_walk_column(sc, j) -> AnyReturn the scratch of column j of sc.
ComposableRecurrences._walk_cotangent Function
_walk_cotangent(x, _::Type) -> AnyReturn the starting cotangents carried back: each Survival's, of its survival from the current lag on, and its hazard's, in the shape of the walk's state.
ComposableRecurrences._walk_fill! Function
_walk_fill!(
K,
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
o,
last
) -> Tuple{Union{AbstractArray{<:Any, 3}, AbstractMatrix}, Any}
_walk_fill!(
K,
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
o,
last,
keep::Val
) -> Tuple{Union{AbstractArray{<:Any, 3}, AbstractMatrix}, Any}Fill the weights K of kernel by walking each cohort's lags, and return them with the walk's scratch.
ComposableRecurrences._walk_groups Function
_walk_groups(x, ks) -> AnyReturn the first stratum of each walk: one walk for all of ks when no Survival has strata, else one walk per stratum.
ComposableRecurrences._walk_hazard! Function
_walk_hazard!(sc, h, st, k, i, τ, l) -> AnyReturn a Survival's hazard at an entry, keeping its partials where sc holds them.
ComposableRecurrences._walk_index Function
_walk_index(sc, g, τ, n) -> AnyReturn the column of group g and cohort τ when every walk is kept, else 1.
ComposableRecurrences._walk_keeps Function
_walk_keeps(x, _::Val{keep}) -> AnyReturn whether every walk of x is kept: when keep is true and x keeps its fill.
ComposableRecurrences._walk_kept Function
_walk_kept(sc) -> BoolReturn whether scratch sc keeps every cohort's walk.
ComposableRecurrences._walk_scratch Function
_walk_scratch(x, _::Type, dims, keep) -> AnyReturn the scratch that the walks of coefficient x record into, its arrays of size dims, or nothing where x holds no Survival or lag map.
ComposableRecurrences._walk_state Function
_walk_state(x, _::Type) -> AnyReturn the walk's starting state: each Survival's survival at the current lag and its hazard's state, a tuple per Derived, nothing elsewhere.
ComposableRecurrences._walk_strata Function
_walk_strata(x, ks, k0) -> AnyReturn the strata that the walk from stratum k0 serves: all of ks when no Survival has strata, else k0 alone.
ComposableRecurrences._walk_total! Function
_walk_total!(
x::ComposableRecurrences.Normalised,
sc,
k,
τ,
o,
_::Type{T}
)Walk the kernel inside x through all of cohort τ's lags into U, and write its normalised weights into W.
ComposableRecurrences._walk_total_back! Function
_walk_total_back!(
x̄,
x::ComposableRecurrences.Normalised,
sc,
k,
τ,
o
)Take the weight cotangents of x back through the map, then back along all of cohort τ's lags of the kernel inside.
ComposableRecurrences._walk_value Function
_walk_value(x, st, k, i, τ, l) -> AnyReturn the value of coefficient x at an entry, from the walk's state st.
ComposableRecurrences._walk_values Function
_walk_values(_::Tuple{}, _::Tuple{}, k, i, τ, l) -> Tuple{}Return the values of arguments a at an entry, from their walk states st.
ComposableRecurrences._walk_weights_back! Function
_walk_weights_back!(
x̄,
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
K̄,
o,
last,
sc
)Take the cotangent K̄ of the weights back to the coefficients' mirror x̄, walking each cohort again unless sc kept its walk.
ComposableRecurrences._walks_strata Function
_walks_strata(x) -> AnyReturn whether a Survival in coefficient x has a strata axis, fixed at compile time from its type.
ComposableRecurrences._walks_strata_type Function
_walks_strata_type(_::Type) -> AnyReturn whether a Survival in a coefficient of type T has a strata axis, from the type.
ComposableRecurrences._weights_array Function
_weights_array(_::Val{false}, _::Type{Tp}, ns, L, n) -> AnyReturn a zero array of weights on L lags of n cohorts, with ns strata first when the first argument is Val(true).
ComposableRecurrences._weights_back! Function
_weights_back!(
_::Nothing,
kernel::TimeVarying{ComposableRecurrences.Primary, <:Union{ComposableRecurrences.LagMap, ComposableRecurrences.Derived, ComposableRecurrences.Survival}},
K̄,
o,
last,
sc
)Take the cotangent K̄ of the weights of kernel back to the mirror x̄ of its coefficients.
ComposableRecurrences._weights_cotangent Function
_weights_cotangent(_::Nothing, K)Return the cotangent of the weights K to fill, or nothing when the kernel's mirror x̄ is absent.
ComposableRecurrences._weights_strata Function
_weights_strata(K::AbstractMatrix) -> Base.OneTo{Int64}Return the strata axis of weights array K, one stratum for a matrix.
ComposableRecurrences._window_before Function
_window_before(_::Nothing, v, prev) -> AnyReturn the time before window v: before its start when given, else the end prev of the window before it, so consecutive windows start after that end.
ComposableRecurrences._window_sum_at! Function
_window_sum_at!(i, out, x, lo, hi, along, m)Write into out[i] the sum of x over one window, with along true when time is the first dimension and m the rows of out.
ComposableRecurrences._window_sums Function
_window_sums(
op::ComposableRecurrences._WindowSums,
,
x::AbstractVector
) -> AnyReturn the sums of x over the windows lo, hi along op.dims.
ComposableRecurrences._window_sums_back! Function
_window_sums_back!(
x̄::AbstractVector,
op::ComposableRecurrences._WindowSums,
,
ȳ
) -> AbstractVectorAdd each window's cotangent in ȳ to x̄ at every time the window covers.
ComposableRecurrences._window_sums_back_at! Function
_window_sums_back_at!(j, x̄, ȳ, lo, hi, along, m)Add to x̄[j] the cotangents of every window its time falls in, with along as in _window_sum_at! and m the rows of x̄.
ComposableRecurrences._windows Function
_windows(
op::ComposableRecurrences._WindowSums
) -> NamedTuple{(:lo, :hi), <:Tuple{Any, Any}}Return (; lo, hi), window v covering times lo[v] + 1 to hi[v], empty when hi[v] <= lo[v].
ComposableRecurrences.depth Function
depth(x) -> Int64Return the number of past outputs x reads from a recurrence's buffer, before the current step.
A Recurrence keeps
past outputs per stratum, where depth and ComposableRecurrences.State holds the last
Arguments
x: any object, such as a modifier, coupling or kernel.
Examples
using ComposableRecurrences
CR = ComposableRecurrences
struct Window
w::Int
end
CR.depth(x::Window) = x.w
x = (Window(5), (; a = Window(9), b = 1.0))
CR.depth(x), CR.depth(CR.Transform(clamp, 0.0, 1.0))
# output
(9, 0)ComposableRecurrences.each! Function
each!(
body,
_::ComposableRecurrences.Serial,
n,
work,
args...
)each!(body, ex::Executor, n, work, args...)Call body(k, args...) for every k in 1:n with executor ex:
where each index k is one stratum or one output time.
body must write only the slots it owns for index k, so the indices can run in any order or at the same time. A new executor type adds a method of each!. Returns nothing.
Arguments
body: the per-index function, called asbody(k, args...).ex: the executor that runs the loop.n: the number of indices.work: an estimate of the loop's total cost in inner operations, which an executor may use to run small loops in order;Serialignores it.args: the arguments passed to every call ofbody.
Examples
using ComposableRecurrences
const CR = ComposableRecurrences
# Row sums of a matrix, one row per index.
rowsum!(k, y, A) = (y[k] = sum(view(A, k, :)); nothing)
A = [1.0 2.0; 3.0 4.0]
y = zeros(2)
CR.each!(rowsum!, CR.Serial(), 2, length(A), y, A)
y
# output
2-element Vector{Float64}:
3.0
7.0ComposableRecurrences.forward Function
Run operator op over a whole call, returning (y, cache).
This is the ComposableRecurrences.Run role: calling the operator lowers to forward(op, Run(), args...; kwargs...). For inputs
with cache holds what the reverse pass needs. Couplings and whole-step modifiers write their outputs in place through ComposableRecurrences.forward! instead.
Arguments
op: the operator.role:Run().args: the call's arguments.
Examples
using ComposableRecurrences
CR = ComposableRecurrences
y, cache = CR.forward(Convolution([0.5, 0.5]), CR.Run(), [1.0, 2.0, 3.0])
y
# output
3-element Vector{Float64}:
0.5
1.5
2.5ComposableRecurrences.ispointwise Function
ispointwise(m) -> BoolReturn whether modifier m acts on each stratum separately: whether its ComposableRecurrences.blocks is (1, 1).
A pointwise modifier's step factorises over the
It follows from blocks, which is the trait to define.
Arguments
m: the modifier.
Examples
using ComposableRecurrences
CR = ComposableRecurrences
CR.ispointwise(CR.Transform(clamp, 0.0, 1.0)), CR.ispointwise(nothing)
# output
(true, false)ComposableRecurrences.param_eltype Function
param_eltype(x) -> AnyReturn the element type the parameters of x contribute to an operator's buffer.
The buffer eltype is the float promotion of this over the kernel, coupling, modifiers, inputs and history,
where param_eltype, so a dual number or a Float32 anywhere sets it. The default recurses by value through fields, tuples and named tuples, so abstractly typed fields count; a Real gives its type and an array of reals its eltype. Add a method for a type whose parameters this does not reach.
Arguments
x: any object, such as a modifier, coupling or kernel.
Examples
using ComposableRecurrences
struct Scale
a
extra::NamedTuple
end
ComposableRecurrences.param_eltype(Scale(1.0f0, (; b = 2)))
# output
Float32Base.reverse Method
reverse(
r::Recurrence
) -> ComposableRecurrences._Reversed{R} where R<:RecurrenceReturn the recurrence r run backwards in time,
in the notation of Recurrence, with r on the time axis reverse(r)(gain = 1; tail, add, start = 1, stop, record).
Arguments
gain,add: as in a call ofr, read at absolute times.
Keyword Arguments
tail: the outputs at timesstop + 1tostop + h, in time order, lengthhorS × h; zeros when left out. APrimary()kernel has no column for those times and takes none.start,stop: the first and last times;stopdefaults to the length ofgainoradd.record:ComposableRecurrences.Pressure()andComposableRecurrences.Trace(), with their columns in time order.ComposableRecurrences.Resume()is anArgumentError.
A TimeVarying array in r is read at its columns start:stop. One given by change points or by a vector per time, or a kernel computed from coefficients, is an ArgumentError. A type of your own is rebuilt from its fields with ConstructionBase.constructorof.
Examples
using ComposableRecurrences
g = [0.6, 0.4]
R = [2.0, 1.0, 0.5, 1.0]
reverse(Recurrence(g))(R; add = R)
# output
4-element Vector{Float64}:
4.896
1.88
0.8
1.0Base.transpose Method
transpose(
c::Convolution
) -> ComposableRecurrences._TransposedConvolutionReturn the transpose of the convolution c, also written c': a sum that reads the series forward from each time rather than back from it,
for a ComposableRecurrences.Primary or fixed kernel, in the notation of Convolution: if c without a gain or add input computes ComposableRecurrences.Secondary kernel (the default for a TimeVarying kernel) weights c' is the same operator, and the transpose of the transpose is c.
Called as transpose(c)(x; tail = nothing, start = 1, stop), it covers the absolute times start:stop:
x: the series, lengthnorS × n, read at absolute timet.tail: the series aftert = n, oldest first (any lengthm, orS × m); later values are zero. A series extended by its last value istail = fill(x[end], L - 1).start: the first time;1by default.stop: the last time;nby default. It may passn + m, where the series is zero, so an output that reads only those times is zero.
The output has the layout of x and length stop - start + 1. A Primary() kernel covers times up to stop, and any other TimeVarying kernel the last time it reads, min(stop + L - 1, n + m).
It takes the direct method whatever the method of c.
Examples
using ComposableRecurrences
c = Convolution([0.5, 0.25, 0.25])
c'([1.0, 2.0, 4.0, 8.0])
# output
4-element Vector{Float64}:
2.0
4.0
4.0
4.0ComposableRecurrences.uses_adjoint Function
uses_adjoint(piece, role) -> BoolReturn whether piece carries its own rule in role: a ComposableRecurrences.pullback! method for that role.
For outputs
directly, where
By default it is true for a modifier written as a pure ComposableRecurrences.step whose float fields are all parameters, and when pullback! has a method for the type of piece and role whose other arguments are untyped, so writing the method is enough. A whole-step modifier with a forward! for ComposableRecurrences.Init needs a pullback! for it too. The lookup is read from the types, so the route costs nothing per call. A method with a typed grads or typed arguments is not found; declare uses_adjoint(::T, role) = true for such a type, which ComposableRecurrences.PieceInterface checks. A method of uses_adjoint also overrides the default, for example when the adjoint covers only some values of a type. If it is true but no pullback! method fits the arguments, the reverse pass throws a MethodError. An operator uses its adjoint in ComposableRecurrences.Run when it has one. A Recurrence does when every float it holds is a Float16, Float32 or Float64 and each component is a pure ComposableRecurrences.step or has a pullback!.
Arguments
piece: the operator, coupling, modifier or depletion form.role: the role.
Examples
using ComposableRecurrences
CR = ComposableRecurrences
CR.uses_adjoint(Recurrence([0.5, 0.5]), CR.Run())
# output
true