Skip to contents

Aggregates caches for different components of TabICL:

  • ColEmbedding cache (for ISAB blocks in column embedding)

  • ICLearning cache (for Encoder layers in the ICL transformer)

Format

An R6::R6Class object.

Details

The train_shape field stores (batch_size, train_size, num_features) as a 3-element integer vector.

Public fields

col_cache

Optional KVCache for ColEmbedding ISAB blocks.

row_repr

Optional torch_tensor. Cached row representations.

icl_cache

Optional KVCache for ICLearning Encoder layers.

train_shape

Integer vector of length 3: (batch_size, train_size, num_features).

num_classes

Optional integer. Number of classes in classification tasks (0 for regression). Stored when caching to ensure consistent output shape during cache use.

Methods


TabICLCache$new()

Create a new TabICLCache.

Initializes sub-caches automatically if not provided.

Usage

TabICLCache$new(
  col_cache = NULL,
  row_repr = NULL,
  icl_cache = NULL,
  train_shape = c(0, 0, 0),
  num_classes = NULL
)

Arguments

col_cache

Optional KVCache.

row_repr

Optional torch_tensor.

icl_cache

Optional KVCache.

train_shape

Integer vector of length 3. Default c(0, 0, 0).

num_classes

Optional integer.


TabICLCache$cache_type()

Return the cache type.

Usage

TabICLCache$cache_type()

Returns

Character string: "kv", "repr", or "empty".


TabICLCache$cache_size_mb()

Return the memory occupied by cached tensors in MB.

Usage

TabICLCache$cache_size_mb()

Returns

Integer.


TabICLCache$is_empty()

Check if the cache is empty.

Usage

TabICLCache$is_empty()

Returns

Logical scalar.


TabICLCache$slice_batch()

Slice this cache along the batch dimension (dim 1 in R).

Usage

TabICLCache$slice_batch(start, end)

Arguments

start

Integer. Start index of the batch slice (1-based, inclusive).

end

Integer. End index of the batch slice (1-based, exclusive).

Returns

A new TabICLCache with sliced tensors (views of original).


TabICLCache$to()

Move all cached tensors to the given device and optionally cast dtype.

Usage

TabICLCache$to(device, dtype = NULL)

Arguments

device

Device string, e.g. "cpu" or "cuda:0".

dtype

Optional torch_dtype. If NULL, preserves existing dtype.

Returns

A new TabICLCache with all tensors on the target device.


TabICLCache$clone()

The objects of this class are cloneable with this method.

Usage

TabICLCache$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
  cache <- TabICLCache$new(
    train_shape = c(4, 100, 20),
    num_classes = 10
  )
  cache$cache_type()
} # }