Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port marian to WASM for inference #24

Merged
merged 46 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fd4989e
Added __unix__ preprocessor around unistd.h
abhi-agg Nov 19, 2020
efe2c09
Enabled compiling only marian decoder
abhi-agg Jan 29, 2021
80ec1a8
cmake changes for marian decoder only builds
abhi-agg Feb 1, 2021
ab29cbc
Added a wasm compatible blas/sgemm submodule "onnxjs"
abhi-agg Feb 1, 2021
6b95d31
Enabled using wasm-compatible sgemm routine of onnxjs
abhi-agg Dec 3, 2020
773d565
Updated intgemm submodule
abhi-agg Feb 2, 2021
b11cd34
Make marian decoder compile on WASM
abhi-agg Feb 4, 2021
f00909e
Prefer if/else in place of try/catch in FastOpt makeScalar (#774)
graemenail Jan 6, 2021
310cba7
Fix to resolve run time failures for FastOpt enabled WASM builds (#779)
qianqianzhu Jan 7, 2021
c3492d3
Enable compilation without using pthreads
abhi-agg Feb 4, 2021
179b8e6
Removed usage of "register" storage type from code
abhi-agg Feb 5, 2021
caf07b3
Updated onnxjs submodule
abhi-agg Feb 5, 2021
5dafba9
Updated sentencepiece submodule
abhi-agg Feb 5, 2021
a7ee4a1
cmake changes (leftover) for marian decoder only builds
abhi-agg Feb 5, 2021
230c4d9
Updated sentencepiece submodule
abhi-agg Feb 5, 2021
9d7767b
Enable "-pthread" compile flag for COMPILE_WITH_PTHREADS=off
abhi-agg Feb 5, 2021
d2dbf9d
Disabled compiling optimizers/quantizer.cpp file for native builds
abhi-agg Feb 5, 2021
ece499d
Change "sentencepiece" submodule URL from "marian-nmt" to "browsermt"
abhi-agg Feb 12, 2021
08f2b79
Added "wasm" folder and "docker"
abhi-agg Feb 12, 2021
4d1de8c
cmake changes for compiling without try/catch
abhi-agg Feb 15, 2021
769e229
Guard try/catch in marian sources (except submodules)
abhi-agg Feb 15, 2021
dcbcb35
Set ASSERTIONS=0 and DISABLE_EXCEPTION_CATCHING=1 for wasm builds
abhi-agg Feb 15, 2021
3c8a34f
Enable Docker wasm build without exceptions
abhi-agg Feb 15, 2021
2b7f788
Remove trailing slash from intgemm submodule since it caused issues i…
motin Feb 19, 2021
9d2d55a
Remove optimizers/quantizer.cpp from decoder only builds
abhi-agg Feb 24, 2021
dd3c24f
Fix binary model loading on 32bit and make wasm debugging possible on…
XapaJIaMnu Mar 1, 2021
900184d
Enabled simd wormhole for wasm builds (docker based)
abhi-agg Mar 3, 2021
3064e36
Updated intgemm submodule
abhi-agg Mar 4, 2021
e516a37
Updated sentencepiece submodule
abhi-agg Mar 4, 2021
2ca2a23
Build only sentencepiece libraries for marian decoder-only builds
abhi-agg Mar 4, 2021
25a200e
Set intgemm's WORMHOLE cmake option to ON when compiling for WASM
abhi-agg Mar 9, 2021
68b516a
Removed dead code from CMakeLists.txt
abhi-agg Mar 9, 2021
9802096
Cleaned up threadpool.h file for USE_PTHREADS pre-processor
abhi-agg Mar 10, 2021
2344432
Removed deadcode from prod.cpp
abhi-agg Mar 10, 2021
cc77573
Appropriate use of DECODER_ONLY preprocessor directive
abhi-agg Mar 16, 2021
3223a50
Updated CHANGELOG file
abhi-agg Mar 18, 2021
f5cbbbb
Small refactoring
abhi-agg Mar 18, 2021
4012fe0
Removed conditional disabling of try/catch blocks in 3rd party sources
abhi-agg Mar 18, 2021
c3fa3a2
Removed conditional disabling of try/catch blocks in marian sources
abhi-agg Mar 18, 2021
5ecfd6c
Cleaned up docker folder, updated wasm README
abhi-agg Mar 9, 2021
79009b5
Added github workflow for wasm builds
abhi-agg Mar 22, 2021
f2f8694
Fixed GPU only builds on Ubuntu
abhi-agg Mar 23, 2021
db82d12
More clean up in wasm folder
abhi-agg Mar 23, 2021
765f830
Aggregate all wasm specific cmake options under one cmake option
abhi-agg Mar 23, 2021
92132b9
Removed COMPILE_DECODER_ONLY cmake option altogether
abhi-agg Mar 23, 2021
ecd063e
Renamed cmake option COMPILE_WITH_PTHREADS to USE_THREADS
abhi-agg Mar 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/macos-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: MacOS WASM

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build-wasm:
name: WASM
runs-on: macos-10.15

steps:
- name: Setup Emscripten toolchain
uses: mymindstorm/setup-emsdk@v8

- name: Verify Emscripten setup
run: emcc -v

- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive

- name: Configure builds
run: |
mkdir -p build-wasm
cd build-wasm
emcmake cmake \
-DCOMPILE_CUDA=off \
-DUSE_DOXYGEN=off \
-DCOMPILE_EXAMPLES=off \
-DCOMPILE_SERVER=off \
-DCOMPILE_TESTS=off \
-DUSE_FBGEMM=off \
-DUSE_SENTENCEPIECE=on \
-DUSE_STATIC_LIBS=on \
-DUSE_MKL=off \
-DCOMPILE_WITHOUT_EXCEPTIONS=on \
-DUSE_WASM_COMPATIBLE_BLAS=on \
-DCOMPILE_DECODER_ONLY=on \
-DCOMPILE_WITH_PTHREADS=off \
-DCOMPILE_WASM=on ../

- name: Compile
working-directory: build-wasm
run: emmake make -j2

- name: Check artifacts
working-directory: build-wasm
run: |
ls -all .
if ls marian-decoder.wasm &>/dev/null && ls marian-decoder.js &>/dev/null
then
echo "Artifacts Successfully Generated"
else
echo "Failure: Artifacts Not Present"
exit 1
fi
7 changes: 5 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
url = https://github.com/marian-nmt/marian-regression-tests
[submodule "src/3rd_party/sentencepiece"]
path = src/3rd_party/sentencepiece
url = https://github.com/marian-nmt/sentencepiece
url = https://github.com/browsermt/sentencepiece
[submodule "src/3rd_party/nccl"]
path = src/3rd_party/nccl
url = https://github.com/marian-nmt/nccl
Expand All @@ -16,7 +16,10 @@
branch = master
[submodule "src/3rd_party/intgemm"]
path = src/3rd_party/intgemm
url = https://github.com/kpu/intgemm/
url = https://github.com/kpu/intgemm
[submodule "src/3rd_party/simple-websocket-server"]
path = src/3rd_party/simple-websocket-server
url = https://github.com/marian-nmt/Simple-WebSocket-Server
[submodule "src/3rd_party/onnxjs"]
path = src/3rd_party/onnxjs
url = https://github.com/abhi-agg/onnxjs.git
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Quantized training (fixed point or log-based quantization) with --quantize-bits N command
- Support for loading lexical shortlist from a binary blob
- Integrate a shortlist converter (which can convert a text lexical shortlist to a binary shortlist) into marian-conv with --shortlist option
- Added ONNXJS submodule to use its wasm-compatible sgemm routine for wasm builds
- Enable compiling marian on wasm platform

### Fixed
- Segfault of spm_train when compiled with -DUSE_STATIC_LIBS=ON seems to have gone away with update to newer SentencePiece version.
Expand All @@ -55,8 +57,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added default "none" for option shuffle in BatchGenerator, so that it works in executables where shuffle is not an option.
- Added a few missing header files in shortlist.h and beam_search.h.
- Improved handling for receiving SIGTERM during training. By default, SIGTERM triggers 'save (now) and exit'. Prior to this fix, batch pre-fetching did not check for this sigal, potentially delaying exit considerably. It now pays attention to that. Also, the default behaviour of save-and-exit can now be disabled on the command line with --sigterm exit-immediately.
- Fix the runtime failures for FASTOPT on 32-bit builds (wasm just happens to be 32-bit) because it uses hashing with an inconsistent mix of uint64_t and size_t.
abhi-agg marked this conversation as resolved.
Show resolved Hide resolved
- Fix loading the binary model on 32-bit builds and for wasm platform

### Changed
- Updated intgemm repository to version 1a176394bb0c2d243c42fe574e063924a92aa120 from https://github.com/kpu/intgemm.
- Changed SentencePiece repository from https://github.com/google/sentencepiece to the version 3ffdc0065a03cadd9d0e5e123aaf9b6ea7ffb05d of https://github.com/browsermt/sentencepiece.
- Updated SentencePiece repository to version 8336bbd0c1cfba02a879afe625bf1ddaf7cd93c5 from https://github.com/google/sentencepiece.
- Enabled compilation of SentencePiece by default since no dependency on protobuf anymore.
- Changed default value of --sentencepiece-max-lines from 10000000 to 2000000 since apparently the new version doesn't sample automatically anymore (Not quite clear how that affects quality of the vocabulary).
Expand All @@ -68,6 +74,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Changed compile flags -Ofast to -O3 and remove --ffinite-math
- Moved old graph groups to depracated folder
- Make cublas and cusparse handle inits lazy to save memory when unused
- Replaced exception-based implementation for type determination in FastOpt::makeScalar

## [1.9.0] - 2020-03-10

Expand Down
158 changes: 117 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,63 @@ endif ()
project(marian CXX C)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(BUILD_ARCH native CACHE STRING "Compile for this CPU architecture.")

# Custom CMake options
option(COMPILE_CPU "Compile CPU version" ON)
option(COMPILE_CUDA "Compile GPU version" ON)
option(COMPILE_EXAMPLES "Compile examples" OFF)
option(COMPILE_SERVER "Compile marian-server" OFF)
option(COMPILE_TESTS "Compile tests" OFF)
option(COMPILE_WASM "Compile marian as WASM target" OFF)
option(COMPILE_DECODER_ONLY "Compile marian-decoder only" OFF)
option(COMPILE_WITH_PTHREADS "Compile with pthreads support" ON)
option(USE_CCACHE "Use ccache compiler cache (https://ccache.dev)" OFF)
option(USE_CUDNN "Use CUDNN library" OFF)
option(USE_DOXYGEN "Build documentation with Doxygen" ON)
option(USE_FBGEMM "Use FBGEMM" OFF)
option(USE_MKL "Compile with MKL support" ON)
option(USE_WASM_COMPATIBLE_BLAS "Compile with a WASM compatible blas for decoder only builds" OFF)
abhi-agg marked this conversation as resolved.
Show resolved Hide resolved
option(COMPILE_WITHOUT_EXCEPTIONS "Compile without exceptions" OFF)
option(USE_MPI "Use MPI library" OFF)
option(USE_NCCL "Use NCCL library" ON)
option(USE_SENTENCEPIECE "Download and compile SentencePiece" ON)
option(USE_STATIC_LIBS "Link statically against non-system libs" OFF)
option(GENERATE_MARIAN_INSTALL_TARGETS "Generate Marian install targets (requires CMake 3.12+)" OFF)
option(M32_BINARIES "Generate 32bit binaries even when building outside outside of WASM. Useful for" OFF)
abhi-agg marked this conversation as resolved.
Show resolved Hide resolved

if(COMPILE_DECODER_ONLY)
set(SPM_BUILD_LIBRARY_ONLY ON CACHE BOOL "Build sentencepiece library only (skip executables)" ON)
endif()

if (COMPILE_WASM)
set(WORMHOLE ON CACHE BOOL "Use WASM wormhole in intgemm https://bugzilla.mozilla.org/show_bug.cgi?id=1672160")
endif()

if(M32_BINARIES OR COMPILE_WASM)
set("BUILD_WIDTH" "-m32")
else(M32_BINARIES OR COMPILE_WASM)
set("BUILD_WIDTH" "-m64")
endif()

if(NOT COMPILE_WASM)
# Setting BUILD_ARCH to native invokes CPU intrinsic detection logic below.
# Prevent invoking that logic for WASM builds.
set(BUILD_ARCH native CACHE STRING "Compile for this CPU architecture.")
endif()

if(COMPILE_DECODER_ONLY)
# Enable building decoder-only source code.
add_compile_definitions(DECODER_ONLY)
endif(COMPILE_DECODER_ONLY)

if(COMPILE_WITH_PTHREADS)
# Need to set compile definition as well
add_compile_definitions(USE_PTHREADS)
endif()

if(COMPILE_WITHOUT_EXCEPTIONS)
add_compile_definitions(WITHOUT_EXCEPTIONS)
endif()

# fbgemm and sentencepiece are both defined with "non-local" installation targets (the source projects don't define them,
# so we define them in src\3rd_party\CMakeLists.txt), but that isn't supported until CMake 3.12. Prior to CMake 3.12,
Expand Down Expand Up @@ -165,6 +204,10 @@ else(MSVC)
set(INTRINSICS "${INTRINSICS} -mavx512f")
list(APPEND INTRINSICS_NVCC -Xcompiler\ -mavx512f)
endif(AVX512_FOUND)
elseif(COMPILE_WASM)
# Can't set to -msse4.1 because onnxjs doesn't compile with this flag. It can be upgraded to
# -msse4.1 once marian can solely be compiled with intgemm ("onnxjs" will be removed in that case)
set(INTRINSICS "-mssse3 -msimd128")
else()
set(INTRINSICS "-msse4.1")
endif()
Expand Down Expand Up @@ -197,24 +240,44 @@ else(MSVC)
set(CMAKE_RDYNAMIC_FLAG "-rdynamic")
endif(CMAKE_COMPILER_IS_GNUCC)

set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_GCC_FLAGS} -fPIC ${DISABLE_GLOBALLY} -march=${BUILD_ARCH} ${INTRINSICS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -m64 -funroll-loops -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_CXX_FLAGS_SLIM "-O3 -m64 -funroll-loops -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
set(CMAKE_CXX_FLAGS_PROFGEN "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-generate -fprofile-correction")
set(CMAKE_CXX_FLAGS_PROFUSE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-use -fprofile-correction")

# these need to be set separately
set(CMAKE_C_FLAGS "-pthread ${CMAKE_GCC_FLAGS} -fPIC ${DISABLE_GLOBALLY} -march=${BUILD_ARCH} ${INTRINSICS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 -m64 -funroll-loops -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_C_FLAGS_SLIM "-O3 -m64 -funroll-loops -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_C_FLAGS_PROFGEN "${CMAKE_C_FLAGS_RELEASE} -fprofile-generate -fprofile-correction")
set(CMAKE_C_FLAGS_PROFUSE "${CMAKE_C_FLAGS_RELEASE} -fprofile-use -fprofile-correction")
if(COMPILE_WASM)
# Setting USE_SSE2 definition to enable SSE2 specific code in "3rd_party/sse_mathfun.h" for wasm builds
add_compile_definitions(USE_SSE2)
# Add compile definition for wasm builds
add_compile_definitions(WASM)
set(PTHREAD_FLAG "-pthread")
set(DISABLE_PTHREAD_MEMGROWTH_WARNING -Wno-error=pthreads-mem-growth)
set(CMAKE_CXX_FLAGS "-std=c++11 ${PTHREAD_FLAG} ${CMAKE_GCC_FLAGS} -fPIC ${DISABLE_GLOBALLY} ${INTRINSICS}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -s WASM=1 -s ASSERTIONS=0 -s DISABLE_EXCEPTION_CATCHING=1 -s LLD_REPORT_UNDEFINED -s FORCE_FILESYSTEM=1 -s ALLOW_MEMORY_GROWTH=1 -g2 ${DISABLE_PTHREAD_MEMGROWTH_WARNING} -funroll-loops")
# Disabling Pthreads + memory growth warning to be an error
# Pthreads + memory growth causes JS accessing the wasm memory to be slow
# https://github.com/WebAssembly/design/issues/1271
list(APPEND ALL_WARNINGS ${DISABLE_PTHREAD_MEMGROWTH_WARNING})

# use our customizations to the generated emscripted html and js resources
set(MARIAN_DECODER_EMSCRIPTEN_LINK_FLAGS "--pre-js ${CMAKE_SOURCE_DIR}/wasm/pre-module.js \
--post-js ${CMAKE_SOURCE_DIR}/wasm/post-module.js \
--shell-file ${CMAKE_SOURCE_DIR}/wasm/custom_shell.html")
else(COMPILE_WASM)
set(CMAKE_CXX_FLAGS "-std=c++11 -pthread ${CMAKE_GCC_FLAGS} -fPIC ${DISABLE_GLOBALLY} -march=${BUILD_ARCH} ${INTRINSICS} ${BUILD_WIDTH}")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_CXX_FLAGS_SLIM "-O3 ${BUILD_WIDTH} -funroll-loops -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
set(CMAKE_CXX_FLAGS_PROFGEN "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-generate -fprofile-correction")
set(CMAKE_CXX_FLAGS_PROFUSE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-use -fprofile-correction")

# these need to be set separately
set(CMAKE_C_FLAGS "-pthread ${CMAKE_GCC_FLAGS} -fPIC ${DISABLE_GLOBALLY} -march=${BUILD_ARCH} ${INTRINSICS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 ${BUILD_WIDTH} -funroll-loops -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g ${CMAKE_RDYNAMIC_FLAG}")
set(CMAKE_C_FLAGS_SLIM "-O3 ${BUILD_WIDTH} -funroll-loops -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_C_FLAGS_PROFGEN "${CMAKE_C_FLAGS_RELEASE} -fprofile-generate -fprofile-correction")
set(CMAKE_C_FLAGS_PROFUSE "${CMAKE_C_FLAGS_RELEASE} -fprofile-use -fprofile-correction")
endif(COMPILE_WASM)
endif(MSVC)

# with gcc 7.0 and above we need to mark fallthrough in switch case statements
Expand All @@ -230,7 +293,12 @@ endif()
if(USE_SENTENCEPIECE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_SENTENCEPIECE -D_USE_INTERNAL_STRING_VIEW")
LIST(APPEND CUDA_NVCC_FLAGS -DUSE_SENTENCEPIECE; )
set(EXT_LIBS ${EXT_LIBS} sentencepiece sentencepiece_train)
if (COMPILE_DECODER_ONLY)
# We don't need sentencepiece_train for decoder-only builds
set(EXT_LIBS ${EXT_LIBS} sentencepiece)
else()
set(EXT_LIBS ${EXT_LIBS} sentencepiece sentencepiece_train)
endif()
endif()

if(USE_ONNX)
Expand Down Expand Up @@ -435,29 +503,37 @@ if(USE_MPI)
endif(USE_MPI)

###############################################################################
# Find MKL
# Find BLAS library for CPU compilation
if(COMPILE_CPU)
set(EXT_LIBS ${EXT_LIBS} intgemm)
if(USE_MKL)
find_package(MKL)
endif(USE_MKL)
if(MKL_FOUND)
include_directories(${MKL_INCLUDE_DIR})
set(EXT_LIBS ${EXT_LIBS} ${MKL_LIBRARIES})
if(USE_WASM_COMPATIBLE_BLAS)
## Use a wasm compatible BLAS
set(EXT_LIBS ${EXT_LIBS} intgemm onnx-sgemm)
set(BLAS_FOUND TRUE)
add_definitions(-DCOMPILE_CPU=1 -DBLAS_FOUND=1 -DMKL_FOUND=1)
else(MKL_FOUND)
set(BLAS_VENDOR "OpenBLAS")
find_package(BLAS)
if(BLAS_FOUND)
include(FindCBLAS)
if(CBLAS_FOUND)
include_directories(${BLAS_INCLUDE_DIR} ${CBLAS_INCLUDE_DIR})
set(EXT_LIBS ${EXT_LIBS} ${BLAS_LIBRARIES} ${CBLAS_LIBRARIES})
add_definitions(-DCOMPILE_CPU=1 -DBLAS_FOUND=1)
endif(CBLAS_FOUND)
endif(BLAS_FOUND)
endif(MKL_FOUND)
set(BLAS_VENDOR "ONNX-SGEMM")
add_compile_definitions(COMPILE_CPU BLAS_FOUND WASM_COMPATIBLE_BLAS)
else(USE_WASM_COMPATIBLE_BLAS)
set(EXT_LIBS ${EXT_LIBS} intgemm)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit could have been outside the if statement

if(USE_MKL)
find_package(MKL)
endif(USE_MKL)
if(MKL_FOUND)
include_directories(${MKL_INCLUDE_DIR})
set(EXT_LIBS ${EXT_LIBS} ${MKL_LIBRARIES})
set(BLAS_FOUND TRUE)
add_definitions(-DCOMPILE_CPU=1 -DBLAS_FOUND=1 -DMKL_FOUND=1)
else(MKL_FOUND)
set(BLAS_VENDOR "OpenBLAS")
find_package(BLAS)
if(BLAS_FOUND)
include(FindCBLAS)
if(CBLAS_FOUND)
include_directories(${BLAS_INCLUDE_DIR} ${CBLAS_INCLUDE_DIR})
set(EXT_LIBS ${EXT_LIBS} ${BLAS_LIBRARIES} ${CBLAS_LIBRARIES})
add_definitions(-DCOMPILE_CPU=1 -DBLAS_FOUND=1)
endif(CBLAS_FOUND)
endif(BLAS_FOUND)
endif(MKL_FOUND)
endif(USE_WASM_COMPATIBLE_BLAS)
endif(COMPILE_CPU)

###############################################################################
Expand Down
Loading