xnn.common.models.hub.cache#

Where the model hub keeps downloaded and converted models.

Every model lives in its own directory under the cache, named after its registry key, so a cache (or any one model directory) can be copied to another system and used there as is:

<cache>/
    mace-off23-small/             card.json  config.yaml  model.pt
    mace-mh-0/raw/mace-mh-0.model (kept: the other heads convert from it)
    mace-mh-0/heads/omat_pbe/     card.json  config.yaml  model.pt
    zenodo.18957344/record.json
    zenodo.18957344/<file>/       card.json  config.yaml  model.pt
    url/<file>-<hash>/            card.json  config.yaml  model.pt

The directory is chosen per call with cache_dir; otherwise default_model_cache_dir() applies.

Functions

default_model_cache_dir()

Return the directory models are cached in when no cache_dir is given.

head_dir(slot, head)

Directory of one head of a multi-head model (the slot itself for none).

is_cache_key(source)

Whether source can name a directory inside the cache.

is_ready(path)

Whether path holds a complete portable model.

offline()

Whether XNN_OFFLINE forbids network access (1/true/yes).

resolve_cache_dir(cache_dir)

The explicit cache_dir (~ expanded) or the default one.

sanitize(name)

Make name safe as one path component (keeps [A-Za-z0-9._-]).

scan(cache)

Yield every complete model directory in the cache.

url_slot(url)

Cache key of a model downloaded from a plain URL.