-
Notifications
You must be signed in to change notification settings - Fork 169
Training mode removal from ONNX nodes #277
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
Conversation
0a3fd29
to
d0f071c
Compare
modelopt/onnx/utils.py
Outdated
break | ||
|
||
# If node has extra training outputs, keep only the first | ||
if len(node.output) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way we can check that that this output that we remove will be the training output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the number of training outputs is operator specific and removing them specifically is a bit more convoluted. I have implemented the same functionality by removing all the unused outputs from a given node if training_mode
is on. Please review.
return make_tensor(name, onnx.TensorProto.FLOAT, shape, data.flatten()) | ||
|
||
|
||
def _make_batchnorm_model(bn_node, extra_value_infos=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment to show how this model will look after creation?
assert "training_mode" not in attr_names | ||
|
||
|
||
def test_remove_node_extra_training_outputs(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add another test to check if there are multiple outputs of a node that are not training outputs, they are not removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the existing test to cover this.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #277 +/- ##
==========================================
+ Coverage 73.83% 73.97% +0.14%
==========================================
Files 173 172 -1
Lines 17402 17351 -51
==========================================
- Hits 12849 12836 -13
+ Misses 4553 4515 -38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1b85154
to
626d99d
Compare
Signed-off-by: Riyad Islam <[email protected]>
Signed-off-by: Riyad Islam <[email protected]>
Signed-off-by: Riyad Islam <[email protected]>
626d99d
to
062224a
Compare
Signed-off-by: Riyad Islam <[email protected]>
What does this PR do?
Type of change: Bug fix
Overview: Training mode removal from a ONNX node was incomplete.
Usage
Testing
Before your PR is "Ready for review"
Additional Information