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.GPCache — Type
GPCachePre-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().
A GPCache holds three dictionaries, keyed by (Symbol, size) tuples:
| Storage | Key type | Value 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.getcache — Function
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.
RxGP.getcache_lowermatrix — Function
getcache_lowermatrix(cache::GPCache, label::Tuple{Symbol, Int})Retrieve (or lazily allocate) a cached LowerTriangular matrix from cache.
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.
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.
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.
RxGP.mul_A_v! — Function
mul_A_v!(cache::GPCache, A, v, sizeA1)In-place matrix-vector multiplication A * v using a cached buffer.