feat(pnnx): convert prelu[num_parameters=1] to leakyrelu, so that it can be fused with conv#6344
Conversation
|
|
|
The binary size change of libncnn.so (bytes)
|
|
this pass shall be in pass_level5 |
…can be fused with conv
done |
|
I'll look at the failed UTs later, 打工人太难了😭 |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
Pull request overview
This PR enhances pnnx graph rewriting to improve downstream fusion opportunities by converting scalar nn.PReLU (num_parameters=1) into nn.LeakyReLU, and also refines float/double serialization to better preserve round-trippable numeric strings in generated artifacts.
Changes:
- Add a level5 graph rewrite pass that converts
nn.PReLU num_parameters=1intonn.LeakyReLUwithnegative_slopetaken from the PReLU weight. - Improve
float_to_string()/double_to_string()formatting by detecting non-roundtrippable default%e/%goutput and retrying with higher precision, plus normalizing exponent formatting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tools/pnnx/src/utils.cpp | Adds exponent normalization and round-trip-aware formatting for float/double string serialization. |
| tools/pnnx/src/pass_level5/fuse_static_prelu.cpp | Adds a rewrite pass to convert scalar PReLU into LeakyReLU to enable later fusions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thanks for your contribution ! |
before:

after:
