diff --git a/.circleci/config.yml b/.circleci/config.yml index 52d58fc09..8892a5845 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: - checkout - run: - name: Build WASM + name: Build Wasm command: | bash build-wasm.sh @@ -77,5 +77,3 @@ workflows: ignore: /.*/ requires: - build - - diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 830924c2c..dbaee0e4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -248,7 +248,7 @@ jobs: run: | ccache -s # Print current cache stats - - name: Import GEMM library from a separate wasm module + - name: Import GEMM library from a separate Wasm module working-directory: build-wasm run: bash ../wasm/patch-artifacts-import-gemm-module.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 82940de82..f57505fec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ endif() if(NOT COMPILE_WASM) # Setting BUILD_ARCH to native invokes CPU intrinsic detection logic below. - # Prevent invoking that logic for WASM builds. + # Prevent invoking that logic for Wasm builds. set(BUILD_ARCH native CACHE STRING "Compile for this CPU architecture.") # Unfortunately MSVC supports a limited subset of BUILD_ARCH flags. Instead try to guess @@ -68,10 +68,10 @@ endif(MSVC) include(CMakeDependentOption) # Project specific cmake options -option(COMPILE_WASM "Compile for WASM" OFF) -cmake_dependent_option(USE_WASM_COMPATIBLE_SOURCE "Use wasm compatible sources" OFF "NOT COMPILE_WASM" ON) +option(COMPILE_WASM "Compile for Wasm" OFF) +cmake_dependent_option(USE_WASM_COMPATIBLE_SOURCE "Use Wasm compatible sources" OFF "NOT COMPILE_WASM" ON) -# WASM disables a million libraries, which also includes the unit test-library. +# Wasm disables a million libraries, which also includes the unit test-library. cmake_dependent_option(COMPILE_UNIT_TESTS "Compile unit tests" OFF "USE_WASM_COMPATIBLE_SOURCE" ON) option(COMPILE_TESTS "Compile bergamot-tests" OFF) cmake_dependent_option(ENABLE_CACHE_STATS "Enable stats on cache" ON "COMPILE_TESTS" OFF) @@ -85,7 +85,7 @@ SET(SSPLIT_COMPILE_LIBRARY_ONLY ON CACHE BOOL "Do not compile ssplit tests") if (USE_WASM_COMPATIBLE_SOURCE) SET(COMPILE_LIBRARY_ONLY ON CACHE BOOL "Build only the Marian library and exclude all executables.") SET(USE_MKL OFF CACHE BOOL "Compile with MKL support") - # # Setting the ssplit-cpp submodule specific cmake options for wasm + # # Setting the ssplit-cpp submodule specific cmake options for Wasm SET(SSPLIT_USE_INTERNAL_PCRE2 ON CACHE BOOL "Use internal PCRE2 instead of system PCRE2") endif() @@ -115,9 +115,9 @@ if(COMPILE_WASM) # See https://github.com/emscripten-core/emscripten/blob/main/src/settings.js list(APPEND WASM_COMPILE_FLAGS -O3 - # Preserve whitespaces in JS even for release builds; this doesn't increase wasm binary size + # Preserve whitespaces in JS even for release builds; this doesn't increase Wasm binary size $<$:-g1> - # Relevant Debug info only for release with debug builds as this increases wasm binary size + # Relevant Debug info only for release with debug builds as this increases Wasm binary size $<$:-g2> -fPIC -mssse3 @@ -128,9 +128,9 @@ if(COMPILE_WASM) ) list(APPEND WASM_LINK_FLAGS -O3 - # Preserve whitespaces in JS even for release builds; this doesn't increase wasm binary size + # Preserve whitespaces in JS even for release builds; this doesn't increase Wasm binary size $<$:-g1> - # Relevant Debug info only for release with debug builds as this increases wasm binary size + # Relevant Debug info only for release with debug builds as this increases Wasm binary size $<$:-g2> -lembind # Save some code, and some speed @@ -154,7 +154,7 @@ if(COMPILE_WASM) # Export all of the intgemm functions in case we need to fall back to using the embedded intgemm -sEXPORTED_FUNCTIONS=[_int8PrepareAFallback,_int8PrepareBFallback,_int8PrepareBFromTransposedFallback,_int8PrepareBFromQuantizedTransposedFallback,_int8PrepareBiasFallback,_int8MultiplyAndAddBiasFallback,_int8SelectColumnsOfBFallback] # Necessary for mozintgemm linking. This prepares the `wasmMemory` variable ahead of time as - # opposed to delegating that task to the wasm binary itself. This way we can link MozIntGEMM + # opposed to delegating that task to the Wasm binary itself. This way we can link MozIntGEMM # module to the same memory as the main bergamot-translator module. -sIMPORTED_MEMORY=1 # Dynamic execution is either frowned upon or blocked inside browser extensions @@ -180,4 +180,3 @@ option(COMPILE_PYTHON "Compile python bindings. Intended to be activated with se if(COMPILE_PYTHON) add_subdirectory(bindings/python) endif(COMPILE_PYTHON) - diff --git a/build-wasm.sh b/build-wasm.sh index b6d70efb6..43a3c84ea 100755 --- a/build-wasm.sh +++ b/build-wasm.sh @@ -41,7 +41,7 @@ cd ${BUILD_DIRECTORY} emcmake cmake -DCOMPILE_WASM=on ../ emmake make -j2 -# 2. Import GEMM library from a separate wasm module +# 2. Import GEMM library from a separate Wasm module bash ../wasm/patch-artifacts-import-gemm-module.sh # The artifacts (.js and .wasm files) will be available in the build directory diff --git a/doc/marian-integration.rst b/doc/marian-integration.rst index 756e0a810..d2895faaa 100644 --- a/doc/marian-integration.rst +++ b/doc/marian-integration.rst @@ -38,7 +38,7 @@ MKL/OpenBLAS. Building bergamot-translator ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Web Assembly (WASM) reduces building to only using a subset of +Web Assembly (Wasm) reduces building to only using a subset of functionalities of marian, the translation library powering bergamot-translator. When developing bergamot-translator it is important that the sources added be compatible with marian. Therefore, it is diff --git a/src/tests/blocking.cpp b/src/tests/blocking.cpp index 3bbb45634..e4279da59 100644 --- a/src/tests/blocking.cpp +++ b/src/tests/blocking.cpp @@ -17,7 +17,7 @@ int main(int argc, char *argv[]) { models.push_back(model); } - /// WASM is one special case where WASM path is being checked, involving translateMultiple and a multi-line feed. + /// Wasm is one special case where Wasm path is being checked, involving translateMultiple and a multi-line feed. /// Hence we do not bind it at a single input-blob single Response constraint imposed by the TestSuite. testSuite.run(config.opMode, models); diff --git a/src/tests/wasm.cpp b/src/tests/wasm.cpp index 97f0fc801..7bbe12f1a 100644 --- a/src/tests/wasm.cpp +++ b/src/tests/wasm.cpp @@ -5,7 +5,7 @@ void wasm(BlockingService &service, std::shared_ptr &model) { std::vector responseOptions; std::vector texts; - // WASM always requires HTML and alignment. + // Wasm always requires HTML and alignment. // TODO(jerinphilip): Fix this, bring in actual tests. // responseOptions.HTML = true; // responseOptions.alignment = true; // Necessary for HTML @@ -35,14 +35,14 @@ int main(int argc, char *argv[]) { for (auto &modelConfigPath : config.modelConfigPaths) { TranslationModel::Config modelConfig = parseOptionsFromFilePath(modelConfigPath); - // Anything WASM is expected to use the byte-array-loads. So we hard-code grabbing MemoryBundle from FS and use the + // Anything Wasm is expected to use the byte-array-loads. So we hard-code grabbing MemoryBundle from FS and use the // MemoryBundle capable constructor. MemoryBundle memoryBundle = getMemoryBundleFromConfig(modelConfig); std::shared_ptr model = std::make_shared(modelConfig, std::move(memoryBundle)); models.push_back(model); } - /// WASM is one special case where WASM path is being checked, involving translateMultiple and a multi-line feed. + /// Wasm is one special case where Wasm path is being checked, involving translateMultiple and a multi-line feed. /// Hence we do not bind it at a single input-blob single Response constraint imposed by the TestSuite. if (config.opMode == "wasm") { wasm(service, models.front()); diff --git a/src/translator/CMakeLists.txt b/src/translator/CMakeLists.txt index 1d773b46b..0597d4eb9 100644 --- a/src/translator/CMakeLists.txt +++ b/src/translator/CMakeLists.txt @@ -20,7 +20,7 @@ add_library(bergamot-translator STATIC xh_scanner.cpp ) if (USE_WASM_COMPATIBLE_SOURCE) - # Using wasm compatible sources should include this compile definition; + # Using Wasm compatible sources should include this compile definition; # Has to be done here because we are including marian headers + some sources # in local repository use these definitions target_compile_definitions(bergamot-translator PUBLIC USE_SSE2 WASM_COMPATIBLE_SOURCE) diff --git a/wasm/CMakeLists.txt b/wasm/CMakeLists.txt index ef8fd988a..ce3c18580 100644 --- a/wasm/CMakeLists.txt +++ b/wasm/CMakeLists.txt @@ -4,7 +4,7 @@ add_executable(bergamot-translator-worker bindings/response_bindings.cpp ) -# Generate version file that can be included in the wasm artifacts +# Generate version file that can be included in the Wasm artifacts configure_file(${CMAKE_CURRENT_SOURCE_DIR}/project_version.js.in ${CMAKE_CURRENT_BINARY_DIR}/project_version.js @ONLY) diff --git a/wasm/README.md b/wasm/README.md index 0f3f77426..57b0b05ff 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -4,7 +4,7 @@ All the instructions below are meant to run from the current directory. ## Using JS APIs -See [node-test.js](./node-test.js) for an annotated example of how to use the WASM module. Most of the code from it can also be used in a browser context. +See [node-test.js](./node-test.js) for an annotated example of how to use the Wasm module. Most of the code from it can also be used in a browser context. Alternatively refer to the file `test_page/js/worker.js` that demonstrates how to use the bergamot translator in JavaScript via a `