liteRtLmCacheFilePathLength function

  1. @visibleForTesting
int liteRtLmCacheFilePathLength(
  1. String cacheDir,
  2. String modelFileName,
  3. int modelSize, {
  4. String tower = _textTower,
})

The length of the path LiteRT-LM gives tower's weight cache in cacheDir: <cacheDir>/<model file name>_<mtime s>_<size><tower>.xnnpack_cache (executor_settings_base.cc GetWeightCacheFile, file_util.cc GetFileCacheIdentifier), with the mtime's seconds taken as 10 digits (every date from 2001 to 2286). The text tower's by default — the vision tower's is 2 characters longer, the audio tower's 8 or 11 — so this is what Windows' MAX_PATH applies to, not the directory's length.

Implementation

@visibleForTesting
int liteRtLmCacheFilePathLength(
  String cacheDir,
  String modelFileName,
  int modelSize, {
  String tower = _textTower,
}) =>
    cacheDir.length +
    1 +
    modelFileName.length +
    '_0000000000_$modelSize'.length +
    tower.length +
    _xnnpackCacheSuffix.length;