Internals Reference

Internals may change

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.

Tracer Types

SparseConnectivityTracer.GradientTracerType
struct 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.

source
SparseConnectivityTracer.HessianTracerType
struct 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.

source
SparseConnectivityTracer.DualType
struct 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

source

Patterns

SparseConnectivityTracer.AbstractPatternType
AbstractPattern

Abstract supertype of all sparsity pattern representations.

Type hierarchy

AbstractPattern
├── AbstractGradientPattern: used in GradientTracer
│   └── IndexSetGradientPattern
└── AbstractHessianPattern: used in HessianTracer
    └── IndexSetHessianPattern
source

Gradient Patterns

SparseConnectivityTracer.IndexSetGradientPatternType
struct 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.
source

Hessian Patterns

SparseConnectivityTracer.IndexSetHessianPatternType
struct 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.

source
SparseConnectivityTracer.DictHessianPatternType
struct 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.

source

Traits

SparseConnectivityTracer.sharedFunction
shared(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.

source

Utilities

SparseConnectivityTracer.myemptyFunction
myempty(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).

source