This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new a6ab8cb857 [Web] Fix NDArrayCache loading report callback (#16631)
a6ab8cb857 is described below

commit a6ab8cb8576df762a009c456c54059547bc643e8
Author: Rick Zhou <[email protected]>
AuthorDate: Fri Feb 23 08:32:50 2024 -0500

    [Web] Fix NDArrayCache loading report callback (#16631)
---
 web/src/runtime.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/web/src/runtime.ts b/web/src/runtime.ts
index cf8d17e772..6ef2255263 100644
--- a/web/src/runtime.ts
+++ b/web/src/runtime.ts
@@ -1512,6 +1512,7 @@ export class Instance implements Disposable {
       totalBytes += list[i].nbytes;
     }
     let fetchedBytes = 0;
+    let fetchedShards = 0;
     let timeElapsed = 0;
 
     const cacheOnly = await artifactCache.hasAllKeys(list.map(key => new 
URL(key.dataPath, ndarrayCacheUrl).href))
@@ -1550,9 +1551,7 @@ export class Instance implements Disposable {
     }
 
     const processShard = async (i: number) => {
-      reportCallback(i);
       const shard = list[i];
-      fetchedBytes += shard.nbytes;
       const dataUrl = new URL(shard.dataPath, ndarrayCacheUrl).href;
       let buffer;
       try {
@@ -1591,6 +1590,8 @@ export class Instance implements Disposable {
         }
       }
       timeElapsed = Math.ceil((perf.now() - tstart) / 1000);
+      fetchedBytes += shard.nbytes;
+      reportCallback(fetchedShards++);
     }
     await Promise.all(list.map((_, index) => processShard(index)));
     reportCallback(list.length);

Reply via email to