-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Fix operators lying about their number of inputs #17049
Conversation
how should we test for this systematically? |
I introduced a test for it in the |
Thanks for carrying through on this issue. I remember running into the problem and getting only as far as describing the issue with this incomplete PR #15834. I reviewed my implementation of the input check there and I like that you have pushed the check down into MakeNode(). However, I notice in my implementation, I was protecting the routine MakeNonLossGradNode, where you don't have a similar check because MakeNode() is called with inputs=null. Could you review my commit above and add a check for MakeNonLossGradNode if you feel it enhances the protection? |
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.
Thanks for adding the check to MakeNonlossGradNode(), which caught additional non-compliant operators. LGTM.
Description
This PR fixes a number of backward operators that advertise the wrong number of inputs (either by having a wrong number passed to
set_num_inputs
or leaving it empty which defaults to 1 input). It also introduces a check inMakeNode
to catch this error.Having consistent number of inputs and outputs is important because tools like
Monitor
rely on them (and currently some of the networks are impossible to inspect during backward because of this) and they are needed for more advanced manipulation of the computational graph.Checklist
Essentials
Please feel free to remove inapplicable items for your PR.