mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
[js/web] only apply max thread number when it's omitted (#7834)
This commit is contained in:
parent
c5ea5907c0
commit
331f20428c
1 changed files with 2 additions and 3 deletions
|
|
@ -20,11 +20,10 @@ export const initializeFlags = (): void => {
|
|||
env.wasm.initTimeout = 0;
|
||||
}
|
||||
|
||||
if (typeof env.wasm.numThreads !== 'number' || !Number.isInteger(env.wasm.numThreads) || env.wasm.numThreads < 0) {
|
||||
if (typeof env.wasm.numThreads !== 'number' || !Number.isInteger(env.wasm.numThreads) || env.wasm.numThreads <= 0) {
|
||||
const numCpuLogicalCores = typeof navigator === 'undefined' ? cpus().length : navigator.hardwareConcurrency;
|
||||
env.wasm.numThreads = Math.ceil((numCpuLogicalCores || 1) / 2);
|
||||
env.wasm.numThreads = Math.min(4, Math.ceil((numCpuLogicalCores || 1) / 2));
|
||||
}
|
||||
env.wasm.numThreads = Math.min(4, env.wasm.numThreads);
|
||||
};
|
||||
|
||||
class OnnxruntimeWebAssemblyBackend implements Backend {
|
||||
|
|
|
|||
Loading…
Reference in a new issue