(
tensorCacheUrl: string,
device: DLDevice,
cacheScopeOrOptions: string | FetchTensorCacheOptions = "tvmjs",
cacheType = "cache",
signal?: AbortSignal,
)
| 1276 | signal?: AbortSignal, |
| 1277 | ): Promise<any>; |
| 1278 | async fetchTensorCache( |
| 1279 | tensorCacheUrl: string, |
| 1280 | device: DLDevice, |
| 1281 | cacheScopeOrOptions: string | FetchTensorCacheOptions = "tvmjs", |
| 1282 | cacheType = "cache", |
| 1283 | signal?: AbortSignal, |
| 1284 | ): Promise<any> { |
| 1285 | let options: FetchTensorCacheOptions; |
| 1286 | if (typeof cacheScopeOrOptions === "object" && cacheScopeOrOptions !== null) { |
| 1287 | options = cacheScopeOrOptions; |
| 1288 | } else { |
| 1289 | options = { |
| 1290 | cacheScope: cacheScopeOrOptions as string, |
| 1291 | signal: signal, |
| 1292 | }; |
| 1293 | } |
| 1294 | const cacheScope = options.cacheScope ?? "tvmjs"; |
| 1295 | const artifactCache = createArtifactCache(cacheScope, { |
| 1296 | ...options, |
| 1297 | cacheType: options.cacheType ?? (cacheType as ArtifactCacheType), |
| 1298 | }); |
| 1299 | const effectiveSignal = options.signal ?? signal; |
| 1300 | const jsonUrl = new URL("tensor-cache.json", tensorCacheUrl).href; |
| 1301 | const list = await artifactCache.fetchWithCache(jsonUrl, "json", effectiveSignal); |
| 1302 | await this.fetchTensorCacheInternal( |
| 1303 | tensorCacheUrl, |
| 1304 | list["records"] as Array<TensorShardEntry>, device, artifactCache, |
| 1305 | effectiveSignal); |
| 1306 | this.cacheMetadata = { ...this.cacheMetadata, ...(list["metadata"] as Record<string, any>) }; |
| 1307 | } |
| 1308 | |
| 1309 | |
| 1310 | /** |
no test coverage detected