DickJC123 commented on a change in pull request #15688: Fix backward_clip num 
inputs and type of clip params
URL: https://github.com/apache/incubator-mxnet/pull/15688#discussion_r310862530
 
 

 ##########
 File path: src/operator/tensor/matrix_op.cc
 ##########
 @@ -763,7 +763,7 @@ parameter values:
 .add_arguments(ClipParam::__FIELDS__());
 
 NNVM_REGISTER_OP(_backward_clip)
-.set_num_inputs(1)
+.set_num_inputs(2)
 
 Review comment:
   I think the bug in this case is the inconsistency between set_num_inputs(1) 
for the _backward_clip node and the definition of the forward node:
   ```
   NNVM_REGISTER_OP(clip)
   ...
    .set_num_inputs(1)
    .set_num_outputs(1)
   ...
   .set_attr<nnvm::FGradient>("FGradient", ElemwiseGradUseIn{ "_backward_clip" 
})
   ```
   Rather than a unittest, I think the framework should detect this problem in 
the general case.  The following CHECK_EQ added to 
./src/operator/operator_common.h flags this problem in test_clip(), but I 
haven't determined whether the entire CI is compatible with it:
   ```
   inline std::vector<nnvm::NodeEntry>CreateNodeEntries(
     nnvm::NodePtr pNode,
     const std::vector<nnvm::NodeEntry>* pOgrads = nullptr,
     const std::vector<nnvm::NodeEntry>* pInputs = nullptr) {
     if (pOgrads)
       pNode->inputs.insert(pNode->inputs.end(), pOgrads->begin(), 
pOgrads->end());
   
     if (pInputs)
       pNode->inputs.insert(pNode->inputs.end(), pInputs->begin(), 
pInputs->end());
   
     CHECK_EQ(pNode->inputs.size(), pNode->num_inputs()) <<
              "Mismatch in number of created vs. expected node inputs.";
   
     std::vector<nnvm::NodeEntry> ret;
     for (uint32_t i = 0; i < pNode->num_outputs(); ++i)
       ret.emplace_back(nnvm::NodeEntry{pNode, i, 0});
   
     return ret;
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to