MCPcopy
hub / github.com/apache/tvm / fetchTensorCache

Method fetchTensorCache

web/src/runtime.ts:1278–1307  ·  view source on GitHub ↗
(
    tensorCacheUrl: string,
    device: DLDevice,
    cacheScopeOrOptions: string | FetchTensorCacheOptions = "tvmjs",
    cacheType = "cache",
    signal?: AbortSignal,
  )

Source from the content-addressed store, hash-verified

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 /**

Callers 1

asyncInitServerMethod · 0.80

Calls 3

createArtifactCacheFunction · 0.90
fetchWithCacheMethod · 0.65

Tested by

no test coverage detected