Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Improved wasm test_page
Browse files Browse the repository at this point in the history
 - test page can load all 5 language pairs
 - Use intgemm.aplha* models
 - start_server.sh script automatically enable simdwormhole via
   APIs that instantiate WASM module
  • Loading branch information
abhi-agg committed Mar 11, 2021
1 parent d1ecd00 commit bf28eda
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion wasm/test_page/bergamot.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<label>Choose the model to use</label>
<input type="radio" name="modellang" value="enes"/><label>English to Spanish</label>
<input type="radio" name="modellang" value="esen" checked/><label>Spanish to English</label>
<input type="radio" name="modellang" value="eten" checked/><label>Estonian to English</label>
<input type="radio" name="modellang" value="enet" checked/><label>English to Estonian</label>
<input type="radio" name="modellang" value="ende" checked/><label>English to German</label>
<input type="button" id="load" value="Load Model"/>
</div>

Expand Down Expand Up @@ -70,7 +73,7 @@
// Set the Model Configuration as YAML formatted string.
// For available configuration options, please check: https://marian-nmt.github.io/docs/cmd/marian-decoder/
const modelConfig = `models:
- /${languagePair}/model.${languagePair}.intgemm.bin
- /${languagePair}/model.${languagePair}.intgemm.alphas.bin
vocabs:
- /${vocabLanguagePair}/vocab.${vocabLanguagePair}.spm
- /${vocabLanguagePair}/vocab.${vocabLanguagePair}.spm
Expand Down
11 changes: 10 additions & 1 deletion wasm/test_page/start_server.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash

echo "Start: Copying artifacts in local folder------"
cp ../../build-wasm/wasm/bergamot-translator-worker.data .
cp ../../build-wasm/wasm/bergamot-translator-worker.js .
cp ../../build-wasm/wasm/bergamot-translator-worker.wasm .
cp ../../build-wasm/wasm/bergamot-translator-worker.worker.js .
echo "Done----"

echo "Start: Enabling wormhole via APIs that compile and instantiate wasm module-------"
sed -i.bak 's/var result = WebAssembly.instantiateStreaming(response, info);/var result = WebAssembly.instantiateStreaming(response, info, {simdWormhole:true});/g' bergamot-translator-worker.js
sed -i.bak 's/return WebAssembly.instantiate(binary, info);/return WebAssembly.instantiate(binary, info, {simdWormhole:true});/g' bergamot-translator-worker.js
sed -i.bak 's/var module = new WebAssembly.Module(bytes);/var module = new WebAssembly.Module(bytes, {simdWormhole:true});/g' bergamot-translator-worker.js
echo "Done: Enabling wormhole via APIs that compile and instantiate wasm module--------"

npm install
echo "Start httpserver"
node bergamot-httpserver.js

0 comments on commit bf28eda

Please sign in to comment.