Skip to content

Commit

Permalink
Merge branch 'Tencent:master' into gemm-quantize-x86
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui authored Oct 29, 2024
2 parents 9c85f62 + c32442a commit 952bedd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,8 @@ else()

unset(CMAKE_REQUIRED_FLAGS)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES "MSVC")
check_cxx_compiler_flag("-mrecip=none" NCNN_COMPILER_SUPPORT_X86_RECIP_NONE)

check_cxx_compiler_flag("/arch:AVX" NCNN_COMPILER_SUPPORT_X86_AVX)

set(CMAKE_REQUIRED_FLAGS "/arch:AVX -mfma -mf16c")
Expand All @@ -543,6 +545,8 @@ else()

unset(CMAKE_REQUIRED_FLAGS)
else()
check_cxx_compiler_flag("-mrecip=none" NCNN_COMPILER_SUPPORT_X86_RECIP_NONE)

check_cxx_compiler_flag("-mavx" NCNN_COMPILER_SUPPORT_X86_AVX)

set(CMAKE_REQUIRED_FLAGS "-mfma -mf16c")
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ if(NCNN_TARGET_ARCH STREQUAL "x86")
target_compile_options(ncnn PRIVATE -msimd128)
endif()
endif()

if(NCNN_COMPILER_SUPPORT_X86_RECIP_NONE)
# recip optimization causes precision loss
target_compile_options(ncnn PRIVATE -mrecip=none)
endif()
endif()

if(NOT NCNN_RUNTIME_CPU AND NCNN_AVX512)
Expand Down

0 comments on commit 952bedd

Please sign in to comment.