add config option wasmPlatformFetch

pull/356/head
Vladimir Mandic 2022-02-10 15:35:32 -05:00
parent f34ada60b9
commit e4862fe8ea
3 changed files with 12 additions and 2 deletions

View File

@ -9,7 +9,10 @@
## Changelog
### **HEAD -> main** 2022/02/07 mandic00@live.com
### **2.6.3** 2022/02/10 mandic00@live.com
### **origin/main** 2022/02/10 mandic00@live.com
### **2.6.2** 2022/02/07 mandic00@live.com

View File

@ -221,6 +221,12 @@ export interface Config {
*/
wasmPath: string,
/** Force WASM loader to use platform fetch
*
* default: auto-detects to link to CDN `jsdelivr` when running in browser
*/
wasmPlatformFetch: false,
/** Print debug statements to console
*
* default: `true`
@ -295,6 +301,7 @@ const config: Config = {
modelBasePath: '',
cacheModels: true,
wasmPath: '',
wasmPlatformFetch: false,
debug: true,
async: true,
warmup: 'full',

View File

@ -77,7 +77,7 @@ export async function check(instance: Human, force = false) {
// customize wasm
if (instance.config.backend === 'wasm') {
if (instance.config.debug) log('wasm path:', instance.config.wasmPath);
if (typeof tf?.setWasmPaths !== 'undefined') await tf.setWasmPaths(instance.config.wasmPath);
if (typeof tf?.setWasmPaths !== 'undefined') await tf.setWasmPaths(instance.config.wasmPath, instance.config.wasmPlatformFetch);
else throw new Error('backend error: attempting to use wasm backend but wasm path is not set');
const simd = await tf.env().getAsync('WASM_HAS_SIMD_SUPPORT');
const mt = await tf.env().getAsync('WASM_HAS_MULTITHREAD_SUPPORT');