Fix: add PIR operator mappers for linear_v2, group_norm, layer_norm - #1645
Closed
PlumBlossomMaid wants to merge 4 commits into
Closed
Fix: add PIR operator mappers for linear_v2, group_norm, layer_norm#1645PlumBlossomMaid wants to merge 4 commits into
PlumBlossomMaid wants to merge 4 commits into
Conversation
Update FAQ.md
PIR format uses positional input indices instead of named inputs. Add linear_v2 mapper from scratch, fix group_norm/layer_norm PIR mode. Verified: nn.Linear/GroupNorm/LayerNorm all export correctly, diff < 1e-6
PlumBlossomMaid
force-pushed
the
fix/pir-op-mappers
branch
from
June 23, 2026 02:20
18dc77b to
dd0d6f5
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds missing/incorrect PIR-mode operator mappers so Paddle models using linear_v2, group_norm, and layer_norm export correctly to ONNX when PIR uses positional IO instead of named IO.
Changes:
- Added a new
linear_v2mapper and registered it for both legacy IR and PIR. - Updated
layer_normandgroup_normmappers to handle PIR positional inputs/outputs. - Added an auto-scan test to validate
nn.Linearexport in PIR mode.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_auto_scan_linear.py |
Adds PIR export coverage for nn.Linear / linear_v2. |
paddle2onnx/mappers_registry.h.in |
Registers LinearV2Mapper for linear_v2. |
paddle2onnx/mapper/nn/linear_v2.h |
Declares the new LinearV2Mapper with PIR + legacy constructors. |
paddle2onnx/mapper/nn/linear_v2.cc |
Implements ONNX lowering for linear_v2 including PIR positional IO. |
paddle2onnx/mapper/nn/layer_norm.cc |
Adds PIR positional IO handling for layer_norm. |
paddle2onnx/mapper/nn/group_norm.h |
Removes manual in_pir_mode override in PIR constructor. |
paddle2onnx/mapper/nn/group_norm.cc |
Reworks group_norm Opset7 path to support PIR positional IO and 3D input handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
56
to
58
| if (has_input_Bias && has_input_Scale) { | ||
| auto scale_info = GetInput("Scale"); | ||
| auto scale_name = scale_info[0].name; |
Comment on lines
197
to
198
| if (has_input_Bias && has_input_Scale) { | ||
| auto scale_info = GetInput("Scale"); |
Comment on lines
+70
to
+78
| // Fallback: create dummy scale/bias if not provided | ||
| if (!has_scale) { | ||
| scale_name = helper_->Constant(GetOnnxDtype(P2ODataType::FP32), | ||
| std::vector<float>(groups_, 1.0)); | ||
| } | ||
| if (!has_bias) { | ||
| bias_name = helper_->Constant(GetOnnxDtype(P2ODataType::FP32), | ||
| std::vector<float>(groups_, 0.0)); | ||
| } |
Comment on lines
+92
to
+95
| std::string dummy_scale = helper_->Constant( | ||
| GetOnnxDtype(P2ODataType::FP32), std::vector<float>(groups_, 1.0)); | ||
| std::string dummy_bias = helper_->Constant( | ||
| GetOnnxDtype(P2ODataType::FP32), std::vector<float>(groups_, 0.0)); |
Comment on lines
+79
to
+81
| } else { | ||
| helper_->MakeNode("Identity", {matmul->output(0)}, {output_name}); | ||
| } |
Comment on lines
+40
to
+42
| if (in_pir_mode) { | ||
| auto x_info = GetInput(0); | ||
| input_name = x_info[0].name; |
…move dead code, fix FP32 hardcoded dtype
PlumBlossomMaid
force-pushed
the
fix/pir-op-mappers
branch
from
June 24, 2026 21:55
e94a4cf to
52a1f90
Compare
Author
|
这个PR被我整的开不开了 #1652 用这个吧 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PIR format uses positional input indices instead of named inputs. Add linear_v2 mapper from scratch, fix group_norm/layer_norm PIR mode.
Verified: NN.Linear/GroupNorm/LayerNorm all export correctly, diff < 1e-6
Fix #1644