MCPcopy Index your code
hub / github.com/apache/tvm / benchmark

Method benchmark

web/src/runtime.ts:932–951  ·  view source on GitHub ↗

* Benchmark stable execution of the run function. * * @param run The run function. * @param dev The device to sync during each run. * @param number The number of times to compute the average. * @param repeat The number of times to repeat the run.

(run: () => void, dev: DLDevice, number = 10, repeat = 1)

Source from the content-addressed store, hash-verified

930 * @param repeat The number of times to repeat the run.
931 */
932 async benchmark(run: () => void, dev: DLDevice, number = 10, repeat = 1): Promise<number[]> {
933 // Skip first run as it can involve GPU warmup and module loading time.
934 const perf = compact.getPerformance();
935 const results = [];
936
937 // run with new scope
938 this.withNewScope(run);
939 await dev.sync();
940
941 for (let k = 0; k < repeat; ++k) {
942 const tstart = perf.now();
943 for (let i = 0; i < number; ++i) {
944 this.withNewScope(run);
945 }
946 await dev.sync();
947 const tend = perf.now();
948 results.push((tend - tstart) / number);
949 }
950 return results;
951 }
952
953 /**
954 * Check whether we enabled asyncify mode

Callers

nothing calls this directly

Calls 2

withNewScopeMethod · 0.95
syncMethod · 0.45

Tested by

no test coverage detected