diff --git a/.github/workflows/linux-riscv64.yml b/.github/workflows/linux-riscv64.yml index c561b287a75c..c9732caad287 100644 --- a/.github/workflows/linux-riscv64.yml +++ b/.github/workflows/linux-riscv64.yml @@ -77,7 +77,6 @@ jobs: run: cmake --build build -j $(nproc) - name: test - continue-on-error: true run: | export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH cd build @@ -95,6 +94,7 @@ jobs: mkdir build && cd build cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/c906-v301.toolchain.cmake -DCMAKE_BUILD_TYPE=release -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF -DNCNN_RUNTIME_CPU=OFF -DNCNN_ZFH=ON -DNCNN_XTHEADVECTOR=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON -DNCNN_BUILD_TESTS=ON .. - name: build + continue-on-error: true run: cmake --build build -j 8 - name: test @@ -116,9 +116,11 @@ jobs: mkdir build && cd build cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/c910-v301.toolchain.cmake -DCMAKE_BUILD_TYPE=release -DNCNN_OPENMP=ON -DNCNN_RUNTIME_CPU=OFF -DNCNN_ZFH=ON -DNCNN_XTHEADVECTOR=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON -DNCNN_BUILD_TESTS=ON .. - name: build + continue-on-error: true run: cmake --build build -j 8 - name: test + continue-on-error: true run: | export PATH=/data/action/osd/Xuantie-qemu-x86_64-Ubuntu-20.04-V5.0.4-B20241127-1130/bin:$PATH cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 646467be61a3..43c67a64002e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -425,7 +425,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv)") endif() set(CMAKE_REQUIRED_FLAGS "-march=rv64gcv") - check_cxx_source_compiles("#include \nint main() { vfloat32m8_t _s, _w; float _v; size_t vl; _s = __riscv_vfmacc_vf_f32m8(_s, _v, _w, vl); return 0; }" NCNN_COMPILER_SUPPORT_RISCV_V) + check_cxx_source_compiles("#include \nint main() { vfloat32m8_t _s, _w; float _v; size_t vl; _s = __riscv_vfmacc_vf_f32m8(_s, _v, _w, vl); vfloat32m1_t _x; vfloat32m1x2_t _xx = __riscv_vcreate_v_f32m1x2(_x, _x); return 0; }" NCNN_COMPILER_SUPPORT_RISCV_V) set(CMAKE_REQUIRED_FLAGS "-march=rv64gc_zfh -D__fp16=_Float16") check_cxx_source_compiles("int main() { __fp16 s, v; s = v * v; return 0; }" NCNN_COMPILER_SUPPORT_RISCV_ZFH) diff --git a/src/layer/x86/unaryop_x86.cpp b/src/layer/x86/unaryop_x86.cpp index e634328d4cb4..ca1e26bdc8fe 100644 --- a/src/layer/x86/unaryop_x86.cpp +++ b/src/layer/x86/unaryop_x86.cpp @@ -575,17 +575,8 @@ struct unary_op_round { NCNN_FORCEINLINE float func(const float& x) const { - // round to nearest even // return (x + 12582912.f) - 12582912.f; -#ifdef FE_TONEAREST - int old_rm = fegetround(); - fesetround(FE_TONEAREST); -#endif - float y = nearbyintf(x); -#ifdef FE_TONEAREST - fesetround(old_rm); -#endif - return y; + return nearbyintf(x); } #if __SSE2__ NCNN_FORCEINLINE __m128 func_pack4(const __m128& x) const @@ -701,7 +692,18 @@ int UnaryOp_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const return unary_op_inplace(bottom_top_blob, opt); if (op_type == Operation_ROUND) - return unary_op_inplace(bottom_top_blob, opt); + { + // round to nearest even +#ifdef FE_TONEAREST + int old_rm = fegetround(); + fesetround(FE_TONEAREST); +#endif + int ret = unary_op_inplace(bottom_top_blob, opt); +#ifdef FE_TONEAREST + fesetround(old_rm); +#endif + return ret; + } if (op_type == Operation_TRUNC) return unary_op_inplace(bottom_top_blob, opt);