From af6cdb2004157a8567db33e6a4e64c97525c4f40 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Sat, 7 May 2022 18:50:29 +0800 Subject: [PATCH] feat(fallback): fix ci GitOrigin-RevId: b6e4e59553a7afe0d7c8dcb2db480f3d266dbacd --- CMakeLists.txt | 10 ++++++++++ dnn/src/fallback/conv_bias/gi/fp32/strategy_5x4.cpp | 13 +++++++++++++ dnn/src/fallback/conv_bias/gi/fp32/strategy_6x3.cpp | 13 +++++++++++++ dnn/test/fallback/gi.cpp | 6 +++--- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55c40bdc..8af8648f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -453,6 +453,16 @@ if(MSVC OR WIN32) # FIXME: fix MegRay on windows message(STATUS "Disable distributed build on windows host build...") set(MGE_WITH_DISTRIBUTED OFF) + if(${MGE_ARCH} STREQUAL "i386" AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") + # https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=msvc-170 + # Workround for error LNK1318 + message( + STATUS + "force use full symbolic debugging with build for 32bit for Windows with Debug mode" + ) + set(CMAKE_C_FLAGS_DEBUG "/Z7") + set(CMAKE_CXX_FLAGS_DEBUG "/Z7") + endif() else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") diff --git a/dnn/src/fallback/conv_bias/gi/fp32/strategy_5x4.cpp b/dnn/src/fallback/conv_bias/gi/fp32/strategy_5x4.cpp index 77bd62c8..c26c9a5e 100644 --- a/dnn/src/fallback/conv_bias/gi/fp32/strategy_5x4.cpp +++ b/dnn/src/fallback/conv_bias/gi/fp32/strategy_5x4.cpp @@ -290,6 +290,13 @@ struct InputTransform5X4 { CONCAT(s, 4).mla(m1addm2, 0.0625f).add(m3addm4).mla(m5addm6, 16.0f); \ } while (0) +#if defined(__GNUC__) && !defined(__llvm__) && !defined(_MSC_VER) +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#if GCC_VERSION < 80000 +#pragma GCC push_options +#pragma GCC optimize("O0") +#endif +#endif template struct OutputTransform5X4 { static void transform( @@ -393,6 +400,12 @@ struct OutputTransform5X4 { } } }; +#if defined(__GNUC__) && !defined(__llvm__) && !defined(_MSC_VER) +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#if GCC_VERSION < 80000 +#pragma GCC pop_options +#endif +#endif #undef OUTPUT_TRANSFORM #undef GET_VECTOR_HIGH_ELEM #undef GET_VECTOR_LOW_ELEM diff --git a/dnn/src/fallback/conv_bias/gi/fp32/strategy_6x3.cpp b/dnn/src/fallback/conv_bias/gi/fp32/strategy_6x3.cpp index 387794ed..9481d7bd 100644 --- a/dnn/src/fallback/conv_bias/gi/fp32/strategy_6x3.cpp +++ b/dnn/src/fallback/conv_bias/gi/fp32/strategy_6x3.cpp @@ -207,6 +207,13 @@ struct InputTransform6X3 { CONCAT(s, 5).mla(m3subm4, 32.f).add(m5subm6).add(m##7); \ } while (0); +#if defined(__GNUC__) && !defined(__llvm__) && !defined(_MSC_VER) +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#if GCC_VERSION < 80000 +#pragma GCC push_options +#pragma GCC optimize("O0") +#endif +#endif template struct OutputTransform6X3 { static void transform( @@ -318,6 +325,12 @@ struct OutputTransform6X3 { } } }; +#if defined(__GNUC__) && !defined(__llvm__) && !defined(_MSC_VER) +#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +#if GCC_VERSION < 80000 +#pragma GCC pop_options +#endif +#endif #undef GET_VECTOR_HIGH_ELEM #undef GET_VECTOR_LOW_ELEM diff --git a/dnn/test/fallback/gi.cpp b/dnn/test/fallback/gi.cpp index e37a872e..d49e1685 100644 --- a/dnn/test/fallback/gi.cpp +++ b/dnn/test/fallback/gi.cpp @@ -905,7 +905,7 @@ TEST_F(FALLBACK, GiMultiplyAddFloat32) { naive.push_back(s1[i] * s2[i] + s0[i]); } - assert_eq((float*)&ret, naive); + assert_lt((float*)&ret, naive, 1e-3); } TEST_F(FALLBACK, GiMultiplyAddScalarFloat32) { @@ -2793,7 +2793,7 @@ TEST_F(FALLBACK, GiMaximumInt8) { for (size_t i = 0; i < SIMD_LEN_8; i++) { s2.push_back(s1[i] < s0[i] ? 0xFF : 0); } - s2.resize(SIMD_LEN); + s2.resize(SIMD_LEN_8); init((int8_t*)&src2, s2, SIMD_LEN_8); ret = GiMaximumInt8(src0, src1); @@ -2853,7 +2853,7 @@ TEST_F(FALLBACK, GiMinimumInt8) { for (size_t i = 0; i < SIMD_LEN_8; i++) { s2.push_back(s1[i] > s0[i] ? 0xFF : 0); } - s2.resize(SIMD_LEN); + s2.resize(SIMD_LEN_8); init((int8_t*)&src2, s2, SIMD_LEN_8); ret = GiMinimumInt8(src0, src1);