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

[Build] WASM static lib build fails: no member named 'Negate' in 'onnxruntime::MLFloat16' #23769

Open
sevagh opened this issue Feb 20, 2025 · 1 comment
Labels
build build issues; typically submitted using template ep:WebGPU ort-web webgpu provider platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@sevagh
Copy link
Contributor

sevagh commented Feb 20, 2025

Describe the issue

When compiling the latest main (af04b20) and using --build_wasm_static_lib, I get a handful of errors related to MLFloat16 missing 'Negate', 'IsNegative', 'FromBits'.

Full build command and error output pasted in the appropriate boxes.

If I swap --build_wasm_static_lib for --build_shared_lib (and keep all other build flags), the compile works fine (I need to add --compile_no_warning_as_error for a minor error:

/home/sevagh/repos-tonalmesh/onnxruntime-webgpu/onnxruntime/core/framework/allocation_planner.cc:192:26: error: ‘maybe_unused’ attribute ignored [-Werror=attributes]
  192 |   const logging::Logger& logger_;

Urgency

No response

Target platform

WebAssembly

Build script

python "${ORT_PATH}/tools/ci_build/build.py" \
            --build_dir="./build/demucs-build-ort-wasm-simd" \
            --config=MinSizeRel \
            --build_wasm_static_lib \
            --parallel \
            --minimal_build \
            --disable_ml_ops \
            --disable_rtti \
            --use_preinstalled_eigen \
            --eigen_path=$(realpath "./thirdparty/eigen") \
            --skip_tests \
            --skip_onnx_tests \
            --enable_wasm_exception_throwing_override \
            --disable_exceptions \
            --include_ops_by_config="./ort-models/demucs/required_operators_and_types.config" \
            --enable_reduced_operator_type_support

Error / output

o_copy_stream_impl.cc.o
[ 15%] Building CXX object CMakeFiles/onnxruntime_mlas.dir/home/sevagh/repos-tonalmesh/onnxruntime-webgpu/onnxruntime/core/mlas/lib/flashattn.cpp.o
/home/sevagh/repos-tonalmesh/onnxruntime-webgpu/onnxruntime/core/mlas/lib/compute.cpp:982:45: error: no member named 'Negate' in 'onnxruntime::MLFloat16'
  982 |         MLAS_FP16 NegativeMaximum = Maximum.Negate();
      |                                     ~~~~~~~ ^
/home/sevagh/repos-tonalmesh/onnxruntime-webgpu/onnxruntime/core/mlas/lib/compute.cpp:983:47: error: no member named 'IsNegative' in 'onnxruntime::MLFloat16'
  983 |         if (SmoothSoftmax && !NegativeMaximum.IsNegative()) {
      |                               ~~~~~~~~~~~~~~~ ^
/home/sevagh/repos-tonalmesh/onnxruntime-webgpu/onnxruntime/core/mlas/lib/compute.cpp:984:42: error: no member named 'FromBits' in 'onnxruntime::MLFloat16'
  984 |             NegativeMaximum = MLAS_FP16::FromBits(0);
      |                               ~~~~~~~~~~~^

Visual Studio Version

No response

GCC / Compiler Version

No response

@sevagh sevagh added the build build issues; typically submitted using template label Feb 20, 2025
@github-actions github-actions bot added ep:WebGPU ort-web webgpu provider platform:web issues related to ONNX Runtime web; typically submitted using template labels Feb 20, 2025
@sevagh
Copy link
Contributor Author

sevagh commented Feb 25, 2025

Turns out my issue is with not enabling WASM threading by default, which does this:

$ git diff cmake/
diff --git a/cmake/onnxruntime_webassembly.cmake b/cmake/onnxruntime_webassembly.cmake
index 8106e46ccf..74d63a4cea 100644
--- a/cmake/onnxruntime_webassembly.cmake
+++ b/cmake/onnxruntime_webassembly.cmake
@@ -85,9 +85,9 @@ function(bundle_static_library bundled_target_name)
 endfunction()

 if (NOT onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
-  add_compile_definitions(
-    BUILD_MLAS_NO_ONNXRUNTIME
-  )
+  #add_compile_definitions(
+  #  BUILD_MLAS_NO_ONNXRUNTIME
+  #)

   # Override re2 compiler options to remove -pthread
   set_property(TARGET re2 PROPERTY COMPILE_OPTIONS )

When I remove BUILD_MLAS_NO_ONNXRUNTIME, this builds again. But, the blame shows that this is rather old so I wonder what other behavior changed to break some FP16 definitions for MLAS_NO_ONNXRUNTIME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template ep:WebGPU ort-web webgpu provider platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

No branches or pull requests

1 participant