Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions extension/wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ list(
embind
executorch_core
extension_data_loader
portable_ops_lib
extension_module_static
extension_tensor
extension_runner_util
Expand All @@ -49,8 +48,12 @@ target_compile_options(executorch_wasm PUBLIC ${_common_compile_options})
target_include_directories(
executorch_wasm PUBLIC ${_common_include_directories}
)
target_link_libraries(executorch_wasm PUBLIC ${link_libraries})
target_link_libraries(
executorch_wasm
PUBLIC ${link_libraries}
INTERFACE executorch_kernels
Copy link
Contributor

Choose a reason for hiding this comment

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

So executorch_kernels is only built when one of the selective build options is enabled - maybe there should be some documentation indicating that wasm build must use the toplevel selective build API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, if none of the selective build options are used, executorch_kernels will default to optimized_native_cpu_ops_lib if EXECUTORCH_BUILD_KERNELS_OPTIMIZED is turned on, portable_ops_lib otherwise.
https://github.com/pytorch/executorch/blob/main/CMakeLists.txt#L885-L892

)

if(EXECUTORCH_BUILD_WASM_TESTS)
if(BUILD_TESTING)
add_subdirectory(test)
endif()
6 changes: 3 additions & 3 deletions extension/wasm/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ add_custom_target(
)

add_executable(executorch_wasm_tests)
target_link_libraries(executorch_wasm_tests PUBLIC executorch_wasm)
target_link_libraries(executorch_wasm_tests PRIVATE executorch_wasm)
target_link_options(
executorch_wasm_tests
PUBLIC
PRIVATE
--embed-file
"${MODELS_DIR}@/"
--post-js
--pre-js
${CMAKE_CURRENT_SOURCE_DIR}/unittests.js
-sASSERTIONS=2
)
Expand Down
4 changes: 2 additions & 2 deletions extension/wasm/test/unittests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* LICENSE file in the root directory of this source tree.
*/

let et;
var Module = {};
const et = Module;
beforeAll((done) => {
et = Module;
et.onRuntimeInitialized = () => {
done();
}
Expand Down
5 changes: 2 additions & 3 deletions scripts/build_wasm_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ cd "$(dirname "${BASH_SOURCE[0]}")/../"
emcmake cmake . -DEXECUTORCH_BUILD_WASM=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_WASM_TESTS=ON \
-DEXECUTORCH_SELECT_OPS_LIST="aten::mm.out,aten::add.out" \
-DEXECUTORCH_BUILD_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-B"${CMAKE_OUT}"

Expand Down
8 changes: 8 additions & 0 deletions tools/cmake/preset/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ define_overridable_option(
EXECUTORCH_COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." BOOL
OFF
)
define_overridable_option(
EXECUTORCH_BUILD_WASM "Build the ExecuTorch JavaScript API" BOOL OFF
)

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
set(_default_executorch_build_pthreadpool OFF)
Expand Down Expand Up @@ -321,6 +324,11 @@ check_conflicting_options_on(
IF_ON EXECUTORCH_SELECT_OPS_LIST CONFLICTS_WITH EXECUTORCH_SELECT_OPS_MODEL
)

check_required_options_on(
IF_ON EXECUTORCH_BUILD_WASM REQUIRES EXECUTORCH_BUILD_EXTENSION_MODULE
EXECUTORCH_BUILD_EXTENSION_TENSOR
)

if(NOT EXISTS ${EXECUTORCH_PAL_DEFAULT_FILE_PATH})
message(
FATAL_ERROR
Expand Down
Loading