When enabling/disabling CPU features or platform-specific APIs, derive decisions from the configured target/platform (toolchain/CMake target selection) and apply consistent compile-time guards across code and tests. Do not rely on compiler-defined feature macros that may differ between build/test environments.
Apply it like this:
# Toolchain for an older/limited target
set(NCNN_AVX OFF CACHE BOOL "Disable AVX" FORCE)
set(NCNN_AVX2 OFF CACHE BOOL "Disable AVX2" FORCE)
set(NCNN_SSE2 ON CACHE BOOL "Enable SSE2" FORCE)
set(CMAKE_SYSTEM_VERSION 5.1)
set(CMAKE_GENERATOR_PLATFORM "Win32")
_WIN32 && !(__MINGW32__) over ad-hoc flags; keep intrinsics loads inside the matching arch block).
#if (defined _WIN32 && !(defined __MINGW32__))
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <process.h>
#endif
#if __ARM_NEON
float32x4_t _k0123 = vld1q_f32(kernel0);
#else
const float* k0 = kernel0;
#endif
__AVX__.This prevents “works in net.cpp, fails in ctest” and “breaks armv7 without NEON” class regressions, and keeps feature gating consistent across the build and runtime/test environments.
Enter the URL of a public GitHub repository