Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Dec 3, 2024
1 parent 2a33a4a commit 932fa71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/linux-riscv64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv)")
endif()

set(CMAKE_REQUIRED_FLAGS "-march=rv64gcv")
check_cxx_source_compiles("#include <riscv_vector.h>\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 <riscv_vector.h>\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)
Expand Down
24 changes: 13 additions & 11 deletions src/layer/x86/unaryop_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -701,7 +692,18 @@ int UnaryOp_x86::forward_inplace(Mat& bottom_top_blob, const Option& opt) const
return unary_op_inplace<unary_op_log10>(bottom_top_blob, opt);

if (op_type == Operation_ROUND)
return unary_op_inplace<unary_op_round>(bottom_top_blob, opt);
{
// round to nearest even
#ifdef FE_TONEAREST
int old_rm = fegetround();
fesetround(FE_TONEAREST);
#endif
int ret = unary_op_inplace<unary_op_round>(bottom_top_blob, opt);
#ifdef FE_TONEAREST
fesetround(old_rm);
#endif
return ret;
}

if (op_type == Operation_TRUNC)
return unary_op_inplace<unary_op_trunc>(bottom_top_blob, opt);
Expand Down

0 comments on commit 932fa71

Please sign in to comment.