Bounded-LRU cache of compiled MPSGraph executables.
Thread-safe. Entries are shared: eviction drops the cache's reference
only. It used to hand out borrowed raw pointers and delete the
executable on eviction, so a module holding one — every CompiledModule
keeps its executables — called freed memory once more than
max_entries signatures had been compiled in the process.
Constructors
1ExecutableCache
void ExecutableCache()Construct an empty cache with the default LRU cap (32 entries). Use set_max_entries to override before inserting.
Destructor
1~ExecutableCache
void ~ExecutableCache()Destructor — releases every cached CompiledExecutable via destroy_executable before the map is torn down.
Static methods
1Operators
1Methods
5Drop the cache's reference to every stored executable.
Look up an executable.
Returns a shared reference on hit (and bumps the entry to most-recent in the LRU order) or an empty pointer on miss.
Insert exec under key and return it. Replaces any existing entry (dropping the cache's reference to the previous executable). If the resulting size exceeds max_entries, drops the least-recently used entries until back at capacity.
Override the LRU cap. Honoured by subsequent inserts; existing entries are not evicted retroactively. Default is 32.
Number of currently-cached entries.