diff --git a/.github/workflows/macos-custom-marian-wasm.yml b/.github/workflows/macos-custom-marian-wasm.yml
index 3e49369..00f5cf7 100644
--- a/.github/workflows/macos-custom-marian-wasm.yml
+++ b/.github/workflows/macos-custom-marian-wasm.yml
@@ -33,6 +33,10 @@ jobs:
working-directory: build-wasm
run: emmake make -j2
+ - name: Instantiate simd wormhole
+ working-directory: build-wasm
+ run: bash ../wasm/patch-artifacts-enable-wormhole.sh
+
- name: Check artifacts
working-directory: build-wasm
run: |
diff --git a/README.md b/README.md
index 2b7f0a6..e70e8cd 100644
--- a/README.md
+++ b/README.md
@@ -46,8 +46,8 @@ Bergamot translator provides a unified API for ([Marian NMT](https://marian-nmt.
If you want to package bergamot project specific models, please follow these instructions:
```bash
mkdir models
- git clone https://github.com/mozilla-applied-ml/bergamot-models
- cp -rf bergamot-models/* models
+ git clone --depth 1 --branch main --single-branch https://github.com/mozilla-applied-ml/bergamot-models
+ cp -rf bergamot-models/prod/* models
gunzip models/*/*
```
@@ -75,11 +75,16 @@ Bergamot translator provides a unified API for ([Marian NMT](https://marian-nmt.
emmake make -j
```
- The artefacts (.js and .wasm files) will be available in `wasm` folder of build directory ("build-wasm" in this case).
+ The wasm artifacts (.js and .wasm files) will be available in `wasm` folder of build directory ("build-wasm" in this case).
+
+ 3. Enable SIMD Wormhole via Wasm instantiation API in generated artifacts
+ ```bash
+ bash ../wasm/patch-artifacts-enable-wormhole.sh
+ ```
#### Recompiling
-As long as you don't update any submodule, just follow steps in `4.ii` to recompile.\
-If you update a submodule, execute following command before executing steps in `4.ii` to recompile.
+As long as you don't update any submodule, just follow steps in `4.ii` and `4.iii` to recompile.\
+If you update a submodule, execute following command before executing steps in `4.ii` and `4.iii` to recompile.
```bash
git submodule update --init --recursive
```
diff --git a/wasm/patch-artifacts-enable-wormhole.sh b/wasm/patch-artifacts-enable-wormhole.sh
new file mode 100644
index 0000000..c16ba66
--- /dev/null
+++ b/wasm/patch-artifacts-enable-wormhole.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+echo "Patching wasm artifacts to enable 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' wasm/bergamot-translator-worker.js
+sed -i.bak 's/return WebAssembly.instantiate(binary, info);/return WebAssembly.instantiate(binary, info, {simdWormhole:true});/g' wasm/bergamot-translator-worker.js
+sed -i.bak 's/var module = new WebAssembly.Module(bytes);/var module = new WebAssembly.Module(bytes, {simdWormhole:true});/g' wasm/bergamot-translator-worker.js
+echo "Done"
diff --git a/wasm/test_page/bergamot.html b/wasm/test_page/bergamot.html
index b4d2027..4f1f2a0 100644
--- a/wasm/test_page/bergamot.html
+++ b/wasm/test_page/bergamot.html
@@ -32,6 +32,9 @@
+
+
+
@@ -70,7 +73,7 @@ En consecuencia, durante el año 2011 se introdujeron 180 proyectos de ley que r
// 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}.npz
+ - /${languagePair}/model.${languagePair}.intgemm.alphas.bin
vocabs:
- /${vocabLanguagePair}/vocab.${vocabLanguagePair}.spm
- /${vocabLanguagePair}/vocab.${vocabLanguagePair}.spm
diff --git a/wasm/test_page/start_server.sh b/wasm/test_page/start_server.sh
index b83344b..b6fc2a6 100644
--- a/wasm/test_page/start_server.sh
+++ b/wasm/test_page/start_server.sh
@@ -1,8 +1,10 @@
#!/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 .
+
npm install
+echo "Start httpserver"
node bergamot-httpserver.js
\ No newline at end of file