Skip to content

fix build for mips loongarch risc-v with simplemath #6024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 27, 2025

Conversation

nihui
Copy link
Member

@nihui nihui commented Apr 27, 2025

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.52%. Comparing base (409f9ae) to head (535e9b7).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6024      +/-   ##
==========================================
+ Coverage   95.41%   95.52%   +0.10%     
==========================================
  Files         825      825              
  Lines      269192   269647     +455     
==========================================
+ Hits       256848   257567     +719     
+ Misses      12344    12080     -264     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nihui nihui requested a review from Copilot April 27, 2025 03:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes build issues in the MIPS MSA simplemath module by replacing calls to the double-precision function "atan2" with the appropriate single-precision "atan2f".

  • Replaced four calls to "atan2" with "atan2f" in the vectorized math function
  • Ensures consistent float precision handling for processing v4f32 data
Comments suppressed due to low confidence (1)

src/layer/mips/msa_mathfun.h:263

  • Replacing 'atan2' with 'atan2f' corrects the precision for float computations; please confirm that similar changes are not needed elsewhere in the module.
tmpx[0] = atan2f(tmpx[0], tmpy[0]);

Copy link

The binary size change of libncnn.so (bytes)

architecture base size pr size difference
x86_64 16465128 16465128 0 😘
armhf 7335260 7335260 0 😘
aarch64 10704800 10704800 0 😘

@nihui nihui changed the title fix build for mips msa simplemath fix build for mips loongarch risc-v with simplemath Apr 27, 2025
@nihui nihui closed this Apr 27, 2025
@nihui nihui reopened this Apr 27, 2025
@nihui nihui requested a review from Copilot April 27, 2025 05:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes build issues on MIPS, Loongarch, and RISC-V platforms by updating math function calls to their float-specific versions (e.g. replacing exp with expf and tanh with tanhf).

  • Updated math functions in GRU implementations and binary/element-wise ops
  • Consistently replaced standard math functions with their f variants across MIPS, Loongarch, and RISC-V files

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/layer/riscv/gru_riscv_zfh.cpp Replaced exp and tanh with expf and tanhf respectively
src/layer/riscv/gru_riscv.cpp Updated math functions to use the f variants
src/layer/riscv/binaryop_riscv_zfh.cpp Changed pow, atan2, etc. to use powf and atan2f
src/layer/riscv/binaryop_riscv.cpp Similar changes with math functions for binary ops
src/layer/mips/unaryop_mips.cpp Replaced fabs, floor, ceil, sqrt, exp, log, sin, etc. with f variants
src/layer/mips/tanh_mips.cpp Updated tanh to tanhf
src/layer/mips/swish_mips.cpp Updated exp to expf
src/layer/mips/softmax_mips.cpp Updated exp to expf in softmax computation
src/layer/mips/sigmoid_mips.cpp Updated sigmoid computation to use expf
src/layer/mips/msa_mathfun.h Replaced atan2 calls with atan2f
src/layer/mips/mish_mips.cpp Updated mish function calls to use tanhf and logf
src/layer/mips/binaryop_mips.cpp Updated pow, atan2, and related functions to use f variants
src/layer/loongarch/unaryop_loongarch.cpp Updated math functions to f variants
src/layer/loongarch/tanh_loongarch.cpp Updated tanh to tanhf
src/layer/loongarch/swish_loongarch.cpp Updated exp to expf
src/layer/loongarch/softmax_loongarch.cpp Updated exp to expf
src/layer/loongarch/sigmoid_loongarch.cpp Updated sigmoid computation to use expf
src/layer/loongarch/mish_loongarch.cpp Updated mish function calls to use tanhf and logf
src/layer/loongarch/lsx_mathfun.h Replaced atan2 with atan2f
src/layer/loongarch/binaryop_loongarch.cpp Updated pow, atan2, and related functions to use f variants

@nihui nihui merged commit c9caafd into Tencent:master Apr 27, 2025
32 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants