Internals Reference
This part of the developer documentation exclusively refers to internals that may change without warning in a future release of SparseConnectivityTracer. Anything written on this page should be treated as if it was undocumented. Only functionality that is exported or part of the user documentation adheres to semantic versioning.
SparseConnectivityTracer.AbstractGradientPattern
SparseConnectivityTracer.AbstractHessianPattern
SparseConnectivityTracer.AbstractPattern
SparseConnectivityTracer.AbstractTracer
SparseConnectivityTracer.DictHessianPattern
SparseConnectivityTracer.Dual
SparseConnectivityTracer.GradientTracer
SparseConnectivityTracer.HessianTracer
SparseConnectivityTracer.IndexSetGradientPattern
SparseConnectivityTracer.IndexSetHessianPattern
SparseConnectivityTracer.TracerLocalSparsityDetector
SparseConnectivityTracer.TracerSparsityDetector
ADTypes.hessian_sparsity
ADTypes.jacobian_sparsity
SparseConnectivityTracer.create_patterns
SparseConnectivityTracer.gradient
SparseConnectivityTracer.hessian
SparseConnectivityTracer.myempty
SparseConnectivityTracer.shared
Tracer Types
SparseConnectivityTracer.AbstractTracer
— TypeAbstractTracer
Abstract supertype of tracers.
Type hierarchy
AbstractTracer
├── GradientTracer
└── HessianTracer
Note that Dual
is not an AbstractTracer
.
SparseConnectivityTracer.GradientTracer
— Typestruct GradientTracer{P<:SparseConnectivityTracer.AbstractGradientPattern} <: SparseConnectivityTracer.AbstractTracer{P<:SparseConnectivityTracer.AbstractGradientPattern}
Real
number type keeping track of non-zero gradient entries.
Fields
pattern::SparseConnectivityTracer.AbstractGradientPattern
: Sparse representation of non-zero entries in the gradient.isempty::Bool
: Indicator whether gradient in tracer contains only zeros.
SparseConnectivityTracer.HessianTracer
— Typestruct HessianTracer{P<:SparseConnectivityTracer.AbstractHessianPattern} <: SparseConnectivityTracer.AbstractTracer{P<:SparseConnectivityTracer.AbstractHessianPattern}
Real
number type keeping track of non-zero gradient and Hessian entries.
Fields
pattern::SparseConnectivityTracer.AbstractHessianPattern
: Sparse representation of non-zero entries in the gradient and the Hessian.isempty::Bool
: Indicator whether gradient and Hessian in tracer both contain only zeros.
SparseConnectivityTracer.Dual
— Typestruct Dual{P<:Real, T<:SparseConnectivityTracer.AbstractTracer} <: Real
Dual Real
number type keeping track of the results of a primal computation as well as a tracer.
Fields
primal::Real
tracer::SparseConnectivityTracer.AbstractTracer
Patterns
SparseConnectivityTracer.AbstractPattern
— TypeAbstractPattern
Abstract supertype of all sparsity pattern representations.
Type hierarchy
AbstractPattern
├── AbstractGradientPattern: used in GradientTracer
│ └── IndexSetGradientPattern
└── AbstractHessianPattern: used in HessianTracer
└── IndexSetHessianPattern
Gradient Patterns
SparseConnectivityTracer.AbstractGradientPattern
— TypeAbstractGradientPattern <: AbstractPattern
Abstract supertype of sparsity patterns representing a vector. For use with GradientTracer
.
Expected interface
SparseConnectivityTracer.IndexSetGradientPattern
— Typestruct IndexSetGradientPattern{I<:Integer, S<:AbstractSet{I<:Integer}} <: SparseConnectivityTracer.AbstractGradientPattern
Gradient sparsity pattern represented by a set.
Fields
gradient::AbstractSet{I} where I<:Integer
: Set of indices $i$ of non-zero values $∇f(x)_i ≠ 0$ in the gradient.
Hessian Patterns
SparseConnectivityTracer.AbstractHessianPattern
— TypeAbstractHessianPattern <: AbstractPattern
Abstract supertype of sparsity patterns representing both gradient and Hessian sparsity. For use with HessianTracer
.
Expected interface
SparseConnectivityTracer.IndexSetHessianPattern
— Typestruct IndexSetHessianPattern{I<:Integer, G<:AbstractSet{I<:Integer}, H<:AbstractSet{Tuple{I<:Integer, I<:Integer}}, SB<:SparseConnectivityTracer.SharingBehavior} <: SparseConnectivityTracer.AbstractHessianPattern
Hessian sparsity pattern represented by two sets.
Fields
gradient::AbstractSet{I} where I<:Integer
: Set of indices $i$ of non-zero values $∇f(x)_i ≠ 0$ in the gradient.hessian::AbstractSet{Tuple{I, I}} where I<:Integer
: Set of index-tuples $(i, j)$ of non-zero values $∇²f(x)_{ij} ≠ 0$ in the Hessian.
Internals
The last type parameter shared
is a Bool
indicating whether the hessian
field of this object should be shared among all intermediate scalar quantities involved in a function.
SparseConnectivityTracer.DictHessianPattern
— Typestruct DictHessianPattern{I<:Integer, S<:AbstractSet{I<:Integer}, D<:AbstractDict{I<:Integer, S<:AbstractSet{I<:Integer}}, shared<:SparseConnectivityTracer.SharingBehavior} <: SparseConnectivityTracer.AbstractHessianPattern
Hessian sparsity pattern represented by a set and a dictionary.
Fields
gradient::AbstractSet{I} where I<:Integer
: Set of indices $i$ of non-zero values $∇f(x)_i ≠ 0$ in the gradient.hessian::AbstractDict{I, S} where {I<:Integer, S<:AbstractSet{I}}
: Dictionary representing index-tuples $(i, j)$ of non-zero values $∇²f(x)_{ij} ≠ 0$ in the Hessian. For a given key $i$, values in the set ${j}$ represent index-tuples ${i, j}$.
Internals
The last type parameter shared
is a Bool
indicating whether the hessian
field of this object should be shared among all intermediate scalar quantities involved in a function.
Traits
SparseConnectivityTracer.shared
— Functionshared(pattern)
Indicates whether patterns always share memory and whether operators are allowed to mutate their AbstractTracer
arguments. Returns either the Shared()
or NotShared()
trait.
If NotShared()
, patterns can share memory and operators are prohibited from mutating AbstractTracer
arguments.
Note
In practice, memory sharing is limited to second-order information in AbstractHessianPattern
.
Utilities
SparseConnectivityTracer.gradient
— Functiongradient(pattern::AbstractTracer)
Return a representation of non-zero values $∇f(x)_{i} ≠ 0$ in the gradient.
SparseConnectivityTracer.hessian
— Functionhessian(pattern::HessianTracer)
Return a representation of non-zero values $∇²f(x)_{ij} ≠ 0$ in the Hessian.
SparseConnectivityTracer.myempty
— Functionmyempty(T)
myempty(tracer::AbstractTracer)
myempty(pattern::AbstractPattern)
Constructor for an empty tracer or pattern of type T
representing a new number (usually an empty pattern).
SparseConnectivityTracer.create_patterns
— Functioncreate_patterns(P, xs, is)
Convenience constructor for patterns of type P
for multiple inputs xs
and their indices is
.