Cache#

class sdm.cache.Cache(*args: Mapping[Hashable, object] | Iterable[tuple[Hashable, object]], **kwargs: object)#

A mutable mapping of model cache values.

Parameters:
class Mode(value)#

The operating mode of a Cache.

A cache alternates between two phases: (1) recording key/value projections from a fit pass, and (2) replaying them across subsequent predict passes. Possible values are:

record#

Allows recording of data.

replay#

Allows replaying of data.

property is_recording: bool#

Whether the cache is in recording mode.

property is_replaying: bool#

Whether the cache is in replaying mode.

size() → int#

The size in bytes of tensor data stored in this cache.

Return type:

int

freeze() → Self#

Freeze the cache to replay mode.

Return type:

Self