mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-09-11 05:35:33 +03:00
JS/WASM: Re-enable importing optimized gemm module for (#336)
- Re-enabled the code that imports optimized gemm module for wasm when available
This commit is contained in:
parent
f6d9233dc4
commit
6b2a855234
@ -14,28 +14,22 @@ function createWasmGemm() {
|
||||
"int8_select_columns_of_b": "int8SelectColumnsOfBFallback"
|
||||
};
|
||||
|
||||
// ToDo: Activate the if code and remove else code once optimized gemm can work without shared array buffer.
|
||||
if (0) {
|
||||
// Name of the optimized gemm implementation.
|
||||
const OPTIMIZED_GEMM = "mozIntGemm";
|
||||
// Name of the optimized gemm implementation.
|
||||
const OPTIMIZED_GEMM = "mozIntGemm";
|
||||
|
||||
const optimizedGemmModule = WebAssembly[OPTIMIZED_GEMM];
|
||||
if (!optimizedGemmModule) {
|
||||
return fallbackGemm(GEMM_TO_FALLBACK_FUNCTIONS_MAP);
|
||||
}
|
||||
|
||||
const optimizedGemmModuleExports = new WebAssembly.Instance(optimizedGemmModule(), {"": {memory: wasmMemory}}).exports;
|
||||
for (let key in GEMM_TO_FALLBACK_FUNCTIONS_MAP) {
|
||||
if (!optimizedGemmModuleExports[key]) {
|
||||
return fallbackGemm(GEMM_TO_FALLBACK_FUNCTIONS_MAP);
|
||||
}
|
||||
}
|
||||
console.log(`Using optimized gemm (${OPTIMIZED_GEMM}) implementation`);
|
||||
return optimizedGemmModuleExports;
|
||||
}
|
||||
else {
|
||||
const optimizedGemmModule = WebAssembly[OPTIMIZED_GEMM];
|
||||
if (!optimizedGemmModule) {
|
||||
return fallbackGemm(GEMM_TO_FALLBACK_FUNCTIONS_MAP);
|
||||
}
|
||||
|
||||
const optimizedGemmModuleExports = new WebAssembly.Instance(optimizedGemmModule(), {"": {memory: wasmMemory}}).exports;
|
||||
for (let key in GEMM_TO_FALLBACK_FUNCTIONS_MAP) {
|
||||
if (!optimizedGemmModuleExports[key]) {
|
||||
return fallbackGemm(GEMM_TO_FALLBACK_FUNCTIONS_MAP);
|
||||
}
|
||||
}
|
||||
console.log(`Using optimized gemm (${OPTIMIZED_GEMM}) implementation`);
|
||||
return optimizedGemmModuleExports;
|
||||
}
|
||||
|
||||
// Return the fallback gemm implementation.
|
||||
|
Loading…
Reference in New Issue
Block a user