Cache utilities

The GPCache system provides pre-allocated matrix and vector storage to avoid repeated heap allocations during message passing. This is critical for performance in large models with many observations.

GPCache

RxGP.GPCacheType
GPCache

Pre-allocated matrix/vector storage to avoid repeated heap allocations during message passing. Holds dictionaries for matrices, vectors, and lower-triangular factors keyed by (Symbol, size) tuples. Create with GPCache().

source

A GPCache holds three dictionaries, keyed by (Symbol, size) tuples:

StorageKey typeValue type
Matrices(Symbol, (nrows, ncols))Matrix{Float64}
Vectors(Symbol, length)Vector{Float64}
Lower-triangular(Symbol, dim)LowerTriangular{Float64}

Create a new cache with GPCache() (all dictionaries start empty; buffers are allocated on first access).

Accessors

RxGP.getcacheFunction
getcache(cache::GPCache, label::Tuple{Symbol, Tuple{Int, Int}})
getcache(cache::GPCache, label::Tuple{Symbol, Int})

Retrieve (or lazily allocate) a cached matrix or vector from cache, keyed by label.

source
RxGP.getcache_lowermatrixFunction
getcache_lowermatrix(cache::GPCache, label::Tuple{Symbol, Int})

Retrieve (or lazily allocate) a cached LowerTriangular matrix from cache.

source

In-place matrix operations

These functions use the cache to perform matrix multiplications without allocating intermediate arrays:

RxGP.mul_A_B!Function
mul_A_B!(cache::GPCache, A, B, sizes...)

In-place matrix multiplication A * B using a pre-allocated buffer from cache.

source
RxGP.mul_A_B_A!Function
mul_A_B_A!(cache::GPCache, A, B, size1)

In-place computation of A * B * A using cached buffers.

source
RxGP.mul_A_B_At!Function
mul_A_B_At!(cache::GPCache, A, B, sizeA1, sizeB1)

In-place computation of A * B * A' using cached buffers.

source
RxGP.mul_A_v!Function
mul_A_v!(cache::GPCache, A, v, sizeA1)

In-place matrix-vector multiplication A * v using a cached buffer.

source