microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
13.87k stars 2.8k forks source link

[Build] Float16_t and BFloat16_t compile error #20564

Open cr-galrosen opened 3 months ago

cr-galrosen commented 3 months ago

Describe the issue

I'm building my project in VS 2017, and getting the compiler error C3615. Only by removing the constexpr from the constructor and static function, the build succeed. I am using version 1.17.3.

Urgency

No response

Target platform

Windows

Build script

/permissive- /Yu"pch.h" /MP /GS /GL /W3 /Gy /Zc:wchar_t /Qspectre /Zi /Gm- /O2 /sdl /Fd /Zc:inline /fp:precise /D "SQLITE_HAS_CODEC" /D "BOOST_USE_STATIC_LIBS" /D "NOMINMAX" /D "WIN32" /D "BOOST_SIGNALS_NO_DEPRECATION_WARNING" /D "ONNXRUNTIME_DYN_LINK" /D "NNG_SHARED_LIB" /D "GTEST_LANG_CXX11=1" /D "GTEST_HAS_TR1_TUPLE=0" /D "BOOST_ALL_NO_LIB" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX /Zc:forScope /Gd /Oi /MD /FC /Fa /EHsc /nologo /Fo /Fp /diagnostics:classic

Error / output

1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): error C3615: constexpr function 'Ort::Float16_t::Float16_t' cannot result in a constant expression (compiling source file .cpp) 1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): note: failure was caused by call of undefined function or one not declared 'constexpr' (compiling source file .cpp) 1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): note: see usage of 'onnxruntime_float16::Float16Impl::Float16Impl' (compiling source file .cpp) 1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): error C3615: constexpr function 'Ort::Float16_t::Float16_t' cannot result in a constant expression (compiling source file .cpp) 1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): note: failure was caused by call of undefined function or one not declared 'constexpr' (compiling source file .cpp) 1>c:.conan\cee678\1\include\onnxruntime_cxx_api.h(171): note: see usage of 'onnxruntime_float16::Float16Impl::Float16Impl' (compiling source file .cpp)

Visual Studio Version

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional>cl Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30154 for x64

GCC / Compiler Version

We build the onnxruntime library with the following conan profile: [settings] os=Windows os_build=Windows arch=x86_64 arch_build=x86_64 compiler=Visual Studio compiler.version=16 build_type=Release

cr-galrosen commented 3 months ago

@snnn @yuslepukhin can you please advise?

snnn commented 3 months ago

Please use the VS 2022 instead.

cr-galrosen commented 3 months ago

@snnn, I tried o build both the onnxruntime library and my application with VS 2022 and I get the same error.

cr-galrosen commented 3 months ago

@snnn, @yuslepukhin can you help here ?

snnn commented 2 months ago

Could you try to set the C++ standard to 17?

cr-galrosen commented 2 months ago

@snnn, Sorry but I still getting the same error.

l333wang commented 2 months ago

Hello, I got the same issues. Severity Code Description Project File Line Suppression State Error C3615 constexpr function 'Ort::Float16_t::Float16_t' cannot result in a constant expression onnxruntime_cxx_api.h 171 My environment is vs2017, c++ standard 17

snnn commented 2 months ago

@yuslepukhin , can you reproduce this error?

cr-galrosen commented 2 months ago

Hi @snnn, any update on this issue?

nianjiuhuiyi commented 1 month ago

I encountered the same mistake in this peoject, SegmentAnything-OnnxRunner , with vs2017 + onnxruntime-win-x64-1.18.0 and c++17. However, it is ok when i used onnxruntime-win-x64-1.14.1.